Add built marshaller files to support GdkPixbufLoader signals
authorHavoc Pennington <hp@redhat.com>
Mon, 22 Jan 2001 23:09:48 +0000 (23:09 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Mon, 22 Jan 2001 23:09:48 +0000 (23:09 +0000)
2001-01-22  Havoc Pennington  <hp@redhat.com>

* Makefile.am: Add built marshaller files to support
GdkPixbufLoader signals

* gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
module location, rather than acting as a fallback, because we are
using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.

* gdk-pixbuf.h: include gdk-pixbuf-loader.h

        * gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
from gtk, and add error to close(), because stop_load may do
parsing of the image.

* pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file

        * io-*.c: make individual operations static, and add fill_vtable
functions which are exported. Fix the collection of type warnings
that surfaced, including a number of functions that didn't
properly take a GError and some that weren't
const-correct. Involved adding error handling for a few loaders.

* gdk-pixbuf-io.h: Add error reporting to stop_load function

* gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
a function that fills in the GdkPixbufModule vtable, instead of
looking up all the image functions individually; this means we
can get type safety within modules for the loader functions.
Also it means you don't have to keep the statically compiled and
GModule versions in sync.

* test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()

* make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()

* gdk-pixbuf.h: nuke gdk_pixbuf_init()

* gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
() here

* gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here

* gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
g_type_init() here

2001-01-22  Havoc Pennington  <hp@redhat.com>

* demos/testanimation.c: fix to reflect gdk-pixbuf changes

* demos/testpixbuf.c: fix to reflect gdk-pixbuf changes

* gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h:
Remove, move back to gdk-pixbuf

* gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
to all the word functions

* gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
before doing anything on NULL layout or if we don't have the focus

* gtk/testtext.c (fill_example_buffer): "justification"

* gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
to be called "justification" not "justify"

* demos/gtk-demo/textview.c (create_tags): "justification"

* gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping

45 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
demos/gtk-demo/textview.c
demos/testanimation.c
demos/testpixbuf.c
gdk-pixbuf/ChangeLog
gdk-pixbuf/Makefile.am
gdk-pixbuf/gdk-pixbuf-animation.c
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/gdk-pixbuf-io.h
gdk-pixbuf/gdk-pixbuf-loader.c
gdk-pixbuf/gdk-pixbuf-loader.h
gdk-pixbuf/gdk-pixbuf-marshal.list [new file with mode: 0644]
gdk-pixbuf/gdk-pixbuf.c
gdk-pixbuf/gdk-pixbuf.h
gdk-pixbuf/io-bmp.c
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-ico.c
gdk-pixbuf/io-jpeg.c
gdk-pixbuf/io-png.c
gdk-pixbuf/io-pnm.c
gdk-pixbuf/io-ras.c
gdk-pixbuf/io-tiff.c
gdk-pixbuf/io-wbmp.c
gdk-pixbuf/io-xbm.c
gdk-pixbuf/io-xpm.c
gdk-pixbuf/make-inline-pixbuf.c
gdk-pixbuf/pixops/have_mmx.S
gdk-pixbuf/test-gdk-pixbuf.c
gtk/Makefile.am
gtk/gdk-pixbuf-loader.c [deleted file]
gtk/gdk-pixbuf-loader.h [deleted file]
gtk/gtktextiter.c
gtk/gtktextiter.h
gtk/gtktextlayout.c
gtk/gtktexttag.c
gtk/gtktexttag.h
gtk/gtktextview.c
gtk/testtext.c
tests/testtext.c

index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 8b6f7f4a20da135375d57da37cec8c3e27b80a72..25b79c7736ffb0ef1f77a18eab3bb86ddf8e2d28 100644 (file)
@@ -1,3 +1,27 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * demos/testanimation.c: fix to reflect gdk-pixbuf changes
+
+       * demos/testpixbuf.c: fix to reflect gdk-pixbuf changes
+
+       * gtk/gdk-pixbuf-loader.c, gtk/gdk-pixbuf-loader.h: 
+       Remove, move back to gdk-pixbuf
+
+       * gtk/gtktextiter.c, gtk/gtktextiter.h: add sentence equivalents
+       to all the word functions
+
+       * gtk/gtktextview.c (gtk_text_view_start_cursor_blink): return
+       before doing anything on NULL layout or if we don't have the focus
+
+       * gtk/testtext.c (fill_example_buffer): "justification"
+
+       * gtk/gtktexttag.h, gtk/gtktexttag.c: change the tag attribute
+       to be called "justification" not "justify"
+
+       * demos/gtk-demo/textview.c (create_tags): "justification"
+       
+       * gtk/gtktextlayout.c (set_para_values): Handle char-wise wrapping
+
 2001-01-22    <alexl@redhat.com>
 
        * gdk/gdkwindow.c (gdk_window_invalidate_region):
index 6a925fd4c0853bd2222bee8f3878dd345dc66f60..4ea37c3824b892294e7c1407ece09ed5784c09b1 100644 (file)
@@ -119,10 +119,10 @@ create_tags (GtkTextBuffer *buffer)
   g_object_set (G_OBJECT (tag), "wrap_mode", GTK_WRAPMODE_NONE, NULL);
   
   tag = gtk_text_buffer_create_tag (buffer, "center");
-  g_object_set (G_OBJECT (tag), "justify", GTK_JUSTIFY_CENTER, NULL);
+  g_object_set (G_OBJECT (tag), "justification", GTK_JUSTIFY_CENTER, NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "right_justify");
-  g_object_set (G_OBJECT (tag), "justify", GTK_JUSTIFY_RIGHT, NULL);
+  g_object_set (G_OBJECT (tag), "justification", GTK_JUSTIFY_RIGHT, NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "wide_margins");
   g_object_set (G_OBJECT (tag),
index fcfbde739f9914b74329d30d1f2c44349f3a39bb..0095ebfa0a8c5b1cecf9b898a3911dd650c4137e 100644 (file)
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <gtk/gtk.h>
-#include <gtk/gdk-pixbuf-loader.h>
+#include <gdk-pixbuf/gdk-pixbuf-loader.h>
 
 typedef struct {
        FILE             *imagefile;
@@ -322,7 +322,7 @@ update_timeout(gpointer data)
        if (done) {
                 gtk_widget_queue_draw(*status->rgbwin);
                gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (status->loader));
-               gtk_object_destroy (GTK_OBJECT(status->loader));
+               g_object_destroy (G_OBJECT(status->loader));
                fclose (status->imagefile);
                g_free (status->buf);
        }
@@ -330,7 +330,6 @@ update_timeout(gpointer data)
        return !done;
 }
 
-
 static void
 progressive_prepared_callback(GdkPixbufLoader* loader, gpointer data)
 {
@@ -459,15 +458,17 @@ main (int argc, char **argv)
                        status.rgbwin = &rgb_window;
 
                        status.buf = g_malloc (readlen);
-                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
-                                           "area_prepared",
-                                           GTK_SIGNAL_FUNC(progressive_prepared_callback),
-                                           &rgb_window);
-
-                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
-                                           "area_updated",
-                                           GTK_SIGNAL_FUNC(progressive_updated_callback),
-                                           &rgb_window);
+                        g_signal_connect_data(G_OBJECT(pixbuf_loader),
+                                              "area_prepared",
+                                              GTK_SIGNAL_FUNC(progressive_prepared_callback),
+                                              &rgb_window,
+                                              NULL, FALSE, FALSE);
+
+                        g_signal_connect_data(G_OBJECT(pixbuf_loader),
+                                              "area_updated",
+                                              GTK_SIGNAL_FUNC(progressive_updated_callback),
+                                              &rgb_window,
+                                              NULL, FALSE, FALSE);
 
                        
                         status.imagefile = fopen (argv[1], "r");
index fac01f6b87e5a962844e6de16a771c4bfbfdfb82..8a5d8f2ddc914028c84e611ab8a0968874c1179a 100644 (file)
@@ -23,7 +23,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <gtk/gtk.h>
-#include <gtk/gdk-pixbuf-loader.h>
+#include <gdk-pixbuf/gdk-pixbuf-loader.h>
 
 #include "test-inline-pixbufs.h"
 
@@ -459,8 +459,9 @@ update_timeout(gpointer data)
 
        if (done) {
                 gtk_widget_queue_draw(*status->rgbwin);
-               gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (status->loader));
-               gtk_object_destroy (GTK_OBJECT(status->loader));
+                /* ignoring errors, we should not do that. */
+               gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (status->loader), NULL);
+               g_object_unref (G_OBJECT(status->loader));
                fclose (status->imagefile);
                g_free (status->buf);
        }
@@ -596,15 +597,17 @@ main (int argc, char **argv)
                        status.rgbwin = &rgb_window;
 
                        status.buf = g_malloc (readlen);
-                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
-                                           "area_prepared",
-                                           GTK_SIGNAL_FUNC(progressive_prepared_callback),
-                                           &rgb_window);
-
-                        gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
-                                           "area_updated",
-                                           GTK_SIGNAL_FUNC(progressive_updated_callback),
-                                           &rgb_window);
+                        g_signal_connect_data (G_OBJECT(pixbuf_loader),
+                                               "area_prepared",
+                                               GTK_SIGNAL_FUNC(progressive_prepared_callback),
+                                               &rgb_window,
+                                               NULL, FALSE, FALSE);
+
+                        g_signal_connect_data (G_OBJECT(pixbuf_loader),
+                                               "area_updated",
+                                               GTK_SIGNAL_FUNC(progressive_updated_callback),
+                                               &rgb_window,
+                                               NULL, FALSE, FALSE);
 
                        
                         status.imagefile = fopen (argv[1], "r");
index e6819670fce7d4270a3019bc06e9a9a1e963c6fd..e9341230cf015c5dee807e2a02e99ab49ffe8918 100644 (file)
@@ -1,3 +1,50 @@
+2001-01-22  Havoc Pennington  <hp@redhat.com>
+
+       * Makefile.am: Add built marshaller files to support
+       GdkPixbufLoader signals
+
+       * gdk-pixbuf-io.c (gdk_pixbuf_load_module): have
+       GDK_PIXBUF_MODULEDIR unconditionally replace the compiled-in
+       module location, rather than acting as a fallback, because we are
+       using GDK_PIXBUF_MODULEDIR to use gdk-pixbuf before installing it.
+
+       * gdk-pixbuf.h: include gdk-pixbuf-loader.h
+
+        * gdk-pixbuf-loader.h, gdk-pixbuf-loader.c: Move back over here
+       from gtk, and add error to close(), because stop_load may do
+       parsing of the image.
+       
+       * pixops/have_mmx.S (_pixops_have_mmx): add newline at end of file
+
+        * io-*.c: make individual operations static, and add fill_vtable
+       functions which are exported. Fix the collection of type warnings
+       that surfaced, including a number of functions that didn't
+       properly take a GError and some that weren't
+       const-correct. Involved adding error handling for a few loaders.
+
+       * gdk-pixbuf-io.h: Add error reporting to stop_load function
+       
+       * gdk-pixbuf-io.c (gdk_pixbuf_load_module): change to just look up
+       a function that fills in the GdkPixbufModule vtable, instead of 
+       looking up all the image functions individually; this means we 
+       can get type safety within modules for the loader functions.
+       Also it means you don't have to keep the statically compiled and 
+       GModule versions in sync. 
+
+       * test-gdk-pixbuf.c (main): remove gdk_pixbuf_init()
+
+       * make-inline-pixbuf.c (main): remove call to gdk_pixbuf_init()
+
+       * gdk-pixbuf.h: nuke gdk_pixbuf_init()
+       
+       * gdk-pixbuf-animation.c (gdk_pixbuf_frame_get_type): g_type_init
+       () here
+
+       * gdk-pixbuf.c (gdk_pixbuf_get_type): g_type_init () here
+
+       * gdk-pixbuf-animation.c (gdk_pixbuf_animation_get_type):
+       g_type_init() here
+
 2001-01-20  John Harper  <jsh@eazel.com>
 
        * io-xbm.c: new pixbuf loader, for X bitmap files. Basically a
index 0d14cb15e370ab6876049609e28f623773a5c924..b6ff3143b2a05873876130ff7923bbe085c59095 100644 (file)
@@ -166,7 +166,7 @@ INCLUDES = -I$(top_srcdir) -I$(top_builddir) \
        -I$(top_srcdir)/gdk-pixbuf \
        -I$(top_builddir)/gdk-pixbuf \
        @INCLUDED_LOADER_DEFINE@ \
-       $(GLIB_CFLAGS)
+       @GLIB_CFLAGS@
 AM_CPPFLAGS = "-DPIXBUF_LIBDIR=\"$(loaderdir)\""
 
 LDADDS = libgdk_pixbuf-1.3.la $(GLIB_LIBS) $(STATIC_LIB_DEPS)
@@ -185,6 +185,8 @@ GDK_PIXBUF_LIBS = $(GLIB_LIBS) $(INTLLIBS)
 # The GdkPixBuf library
 #
 
+BUILT_SOURCES=gdk-pixbuf-marshal.h gdk-pixbuf-marshal.c
+
 libgdk_pixbufincludedir = $(includedir)/gtk-2.0/gdk-pixbuf
 
 libgdk_pixbuf_1_3_la_SOURCES =         \
@@ -193,6 +195,8 @@ libgdk_pixbuf_1_3_la_SOURCES =      \
        gdk-pixbuf-animation.c  \
        gdk-pixbuf-data.c       \
        gdk-pixbuf-io.c         \
+       gdk-pixbuf-loader.c     \
+       gdk-pixbuf-marshal.h    \
        gdk-pixbuf-scale.c      \
        gdk-pixbuf-util.c
 
@@ -205,6 +209,7 @@ libgdk_pixbuf_1_3_la_DEPENDENCIES = $(builtin_objs)
 
 libgdk_pixbufinclude_HEADERS = \
        gdk-pixbuf.h            \
+       gdk-pixbuf-loader.h     \
        gdk-pixbuf-features.h
 
 noinst_HEADERS =               \
@@ -227,3 +232,15 @@ EXTRA_DIST =                       \
        pixbufloader_wbmp.def           \
        pixbufloader_xbm.def
 
+
+gdk-pixbuf-marshal.h: gdk-pixbuf-marshal.list
+       cd $(srcdir) \
+       && glib-genmarshal --prefix=gdk_pixbuf_marshal gdk-pixbuf-marshal.list --header >> xgen-gmh \
+       && (cmp -s xgen-gmh gdk-pixbuf-marshal.h || cp xgen-gmh gdk-pixbuf-marshal.h) \
+       && rm -f xgen-gmh xgen-gmh~
+
+gdk-pixbuf-marshal.c: gdk-pixbuf-marshal.list
+       cd $(srcdir) \
+       && glib-genmarshal --prefix=gdk_pixbuf_marshal gdk-pixbuf-marshal.list --body >> xgen-gmh \
+       && (cmp -s xgen-gmh gdk-pixbuf-marshal.c || cp xgen-gmh gdk-pixbuf-marshal.c) \
+       && rm -f xgen-gmh xgen-gmh~
index d0f7768f2cf3f3b6272f0c489bcb37e6b2ea36de..b833996fa5d323e5160b23f843a84325f96e33b6 100644 (file)
@@ -50,7 +50,9 @@ gdk_pixbuf_animation_get_type (void)
                         0,              /* n_preallocs */
                         (GInstanceInitFunc) NULL,
                 };
-      
+
+                g_type_init ();
+                
                 object_type = g_type_register_static (G_TYPE_OBJECT,
                                                       "GdkPixbufAnimation",
                                                       &object_info, 0);
@@ -457,6 +459,8 @@ gdk_pixbuf_frame_get_type (void)
 
   if (our_type == 0)
     {
+      g_type_init ();
+      
       our_type = g_boxed_type_register_static ("GdkPixbufFrame",
                                                gdk_pixbuf_frame_copy,
                                                gdk_pixbuf_frame_free);
index 469f4743728ab2ce9f1f68cd7e90309c2745c7ed..ef675dc06860f68f87265d44efd6973df5f8eec2 100644 (file)
@@ -260,281 +260,173 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module,
        char *module_name;
        char *path;
        GModule *module;
-       gpointer load_sym;
-        gpointer save_sym;
+       gpointer sym;
        char *name;
+        gboolean retval;
+        char *dir;
        
         g_return_val_if_fail (image_module->module == NULL, FALSE);
 
        name = image_module->module_name;
        
        module_name = g_strconcat ("pixbufloader-", name, NULL);
-       path = g_module_build_path (PIXBUF_LIBDIR, module_name);
-
-       module = g_module_open (path, G_MODULE_BIND_LAZY);
-       if (!module) {
-                /* Debug feature, check in GDK_PIXBUF_MODULEDIR, or working directory */
-               char *dir = g_getenv ("GDK_PIXBUF_MODULEDIR");
-               if (!dir)
-                       dir = "";
-         
-                g_free (path);
-                path = g_module_build_path (dir, module_name);
+
+        /* This would be an exploit in an suid binary using gdk-pixbuf,
+         * but see http://www.gtk.org/setuid.html or the BugTraq
+         * archives for why you should report this as a bug against
+         * setuid apps using this library rather than the library
+         * itself.
+         */
+        dir = g_getenv ("GDK_PIXBUF_MODULEDIR");
+
+        if (dir == NULL || *dir == '\0') {
+                
+                path = g_module_build_path (PIXBUF_LIBDIR, module_name);
                 module = g_module_open (path, G_MODULE_BIND_LAZY);
+        } else {
+                path = g_module_build_path (dir, module_name);
+                module = g_module_open (path, G_MODULE_BIND_LAZY);                
+        }        
 
-                if (!module) {
-                        g_set_error (error,
-                                     GDK_PIXBUF_ERROR,
-                                     GDK_PIXBUF_ERROR_FAILED,
-                                     _("Unable to load image-loading module: %s: %s"),
-                                     path, g_module_error ());
-                        g_free (module_name);
-                        g_free (path);
-                        return FALSE;
-                }
-                g_free (path);
-       } else {
+        if (!module) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_FAILED,
+                             _("Unable to load image-loading module: %s: %s"),
+                             path, g_module_error ());
+                g_free (module_name);
                 g_free (path);
+                return FALSE;
         }
 
         g_free (module_name);
 
-       image_module->module = module;
-
-       if (pixbuf_module_symbol (module, name, "image_load", &load_sym))
-               image_module->load = load_sym;
-
-        if (pixbuf_module_symbol (module, name, "image_load_xpm_data", &load_sym))
-               image_module->load_xpm_data = load_sym;
-
-        if (pixbuf_module_symbol (module, name, "image_begin_load", &load_sym))
-               image_module->begin_load = load_sym;
-
-        if (pixbuf_module_symbol (module, name, "image_stop_load", &load_sym))
-               image_module->stop_load = load_sym;
-
-        if (pixbuf_module_symbol (module, name, "image_load_increment", &load_sym))
-               image_module->load_increment = load_sym;
-
-        if (pixbuf_module_symbol (module, name, "image_load_animation", &load_sym))
-               image_module->load_animation = load_sym;
+       image_module->module = module;        
+        
+        if (pixbuf_module_symbol (module, name, "fill_vtable", &sym)) {
+                ModuleFillVtableFunc func = sym;
+                (* func) (image_module);
+                retval = TRUE;
+        } else {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_FAILED,
+                             _("Image-loading module %s does not export the proper interface; perhaps it's from a different GTK version?"),
+                             path);
+                retval = FALSE;
+        }
 
-        if (pixbuf_module_symbol (module, name, "image_save", &save_sym))
-          image_module->save = save_sym;
+        g_free (path);
 
-        return TRUE;
+        return retval;
 }
 #else
 
 #define mname(type,fn) gdk_pixbuf__ ## type ## _image_ ##fn
-#define m_load(type)  extern GdkPixbuf * mname(type,load) (FILE *f, GError **error);
-#define m_load_xpm_data(type)  extern GdkPixbuf * mname(type,load_xpm_data) (const char **data);
-#define m_begin_load(type)  \
-   extern gpointer mname(type,begin_load) (ModulePreparedNotifyFunc prepare_func, \
-                                ModuleUpdatedNotifyFunc update_func, \
-                                ModuleFrameDoneNotifyFunc frame_done_func,\
-                                ModuleAnimationDoneNotifyFunc anim_done_func,\
-                                gpointer user_data,\
-                                GError **error);
-#define m_stop_load(type)  extern void mname(type,stop_load) (gpointer context);
-#define m_load_increment(type)  extern gboolean mname(type,load_increment) (gpointer context, const guchar *buf, guint size, GError **error);
-#define m_load_animation(type)  extern GdkPixbufAnimation * mname(type,load_animation) (FILE *f, GError **error);
-#define m_save(type) \
-   extern gboolean mname(type,save) (FILE          *f, \
-                                    GdkPixbuf     *pixbuf, \
-                                     gchar        **keys, \
-                                    gchar        **values, \
-                                    GError       **error);
-
-/* PNG */
-m_load (png);
-m_begin_load (png);
-m_load_increment (png);
-m_stop_load (png);
-m_save (png);
-/* BMP */
-m_load (bmp);
-m_begin_load (bmp);
-m_load_increment (bmp);
-m_stop_load (bmp);
-/* WBMP */
-m_load (wbmp);
-m_begin_load (wbmp);
-m_load_increment (wbmp);
-m_stop_load (wbmp);
-/* GIF */
-m_load (gif);
-m_begin_load (gif);
-m_load_increment (gif);
-m_stop_load (gif);
-m_load_animation (gif);
-/* ICO */
-m_load (ico);
-m_begin_load (ico);
-m_load_increment (ico);
-m_stop_load (ico);
-/* JPEG */
-m_load (jpeg);
-m_begin_load (jpeg);
-m_load_increment (jpeg);
-m_stop_load (jpeg);
-m_save (jpeg);
-/* PNM */
-m_load (pnm);
-m_begin_load (pnm);
-m_load_increment (pnm);
-m_stop_load (pnm);
-/* RAS */
-m_load (ras);
-m_begin_load (ras);
-m_load_increment (ras);
-m_stop_load (ras);
-/* TIFF */
-m_load (tiff);
-m_begin_load (tiff);
-m_load_increment (tiff);
-m_stop_load (tiff);
-/* XPM */
-m_load (xpm);
-m_load_xpm_data (xpm);
-/* XBM */
-m_load (xbm);
-m_begin_load (xbm);
-m_load_increment (xbm);
-m_stop_load (xbm);
+#define m_fill_vtable(type) extern void mname(type,fill_vtable) (GdkPixbufModule *module)
+
+m_fill_vtable (png);
+m_fill_vtable (bmp);
+m_fill_vtable (wbmp);
+m_fill_vtable (gif);
+m_fill_vtable (ico);
+m_fill_vtable (jpeg);
+m_fill_vtable (pnm);
+m_fill_vtable (ras);
+m_fill_vtable (tiff);
+m_fill_vtable (xpm);
+m_fill_vtable (xbm);
 
 gboolean
 gdk_pixbuf_load_module (GdkPixbufModule *image_module,
                         GError         **error)
 {
+        ModuleFillVtableFunc fill_vtable = NULL;
        image_module->module = (void *) 1;
 
+        if (FALSE) {
+                /* Ugly hack so we can use else if unconditionally below ;-) */
+        }
+        
 #ifdef INCLUDE_png     
-       if (strcmp (image_module->module_name, "png") == 0){
-               image_module->load           = mname (png,load);
-               image_module->begin_load     = mname (png,begin_load);
-               image_module->load_increment = mname (png,load_increment);
-               image_module->stop_load      = mname (png,stop_load);
-                image_module->save           = mname (png,save);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "png") == 0){
+                fill_vtable = mname (png, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_bmp     
-       if (strcmp (image_module->module_name, "bmp") == 0){
-               image_module->load           = mname (bmp,load);
-               image_module->begin_load     = mname (bmp,begin_load);
-               image_module->load_increment = mname (bmp,load_increment);
-               image_module->stop_load      = mname (bmp,stop_load);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "bmp") == 0){
+                fill_vtable = mname (bmp, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_wbmp
-       if (strcmp (image_module->module_name, "wbmp") == 0){
-               image_module->load           = mname (wbmp,load);
-               image_module->begin_load     = mname (wbmp,begin_load);
-               image_module->load_increment = mname (wbmp,load_increment);
-               image_module->stop_load      = mname (wbmp,stop_load);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "wbmp") == 0){
+                fill_vtable = mname (wbmp, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_gif
-       if (strcmp (image_module->module_name, "gif") == 0){
-               image_module->load           = mname (gif,load);
-               image_module->begin_load     = mname (gif,begin_load);
-               image_module->load_increment = mname (gif,load_increment);
-               image_module->stop_load      = mname (gif,stop_load);
-               image_module->load_animation = mname (gif,load_animation);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "gif") == 0){
+                fill_vtable = mname (gif, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_ico
-       if (strcmp (image_module->module_name, "ico") == 0){
-               image_module->load           = mname (ico,load);
-               image_module->begin_load     = mname (ico,begin_load);
-               image_module->load_increment = mname (ico,load_increment);
-               image_module->stop_load      = mname (ico,stop_load);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "ico") == 0){
+                fill_vtable = mname (ico, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_jpeg
-       if (strcmp (image_module->module_name, "jpeg") == 0){
-               image_module->load           = mname (jpeg,load);
-               image_module->begin_load     = mname (jpeg,begin_load);
-               image_module->load_increment = mname (jpeg,load_increment);
-               image_module->stop_load      = mname (jpeg,stop_load);
-                image_module->save           = mname (jpeg,save);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "jpeg") == 0){
+                fill_vtable = mname (jpeg, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_pnm
-       if (strcmp (image_module->module_name, "pnm") == 0){
-               image_module->load           = mname (pnm,load);
-               image_module->begin_load     = mname (pnm,begin_load);
-               image_module->load_increment = mname (pnm,load_increment);
-               image_module->stop_load      = mname (pnm,stop_load);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "pnm") == 0){
+                fill_vtable = mname (pnm, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_ras
-       if (strcmp (image_module->module_name, "ras") == 0){
-               image_module->load           = mname (ras,load);
-               image_module->begin_load     = mname (ras,begin_load);
-               image_module->load_increment = mname (ras,load_increment);
-               image_module->stop_load      = mname (ras,stop_load);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "ras") == 0){
+                fill_vtable = mname (ras, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_tiff
-       if (strcmp (image_module->module_name, "tiff") == 0){
-               image_module->load           = mname (tiff,load);
-               image_module->begin_load     = mname (tiff,begin_load);
-               image_module->load_increment = mname (tiff,load_increment);
-               image_module->stop_load      = mname (tiff,stop_load);
-               return TRUE;
-       }
-#endif
-
-#ifdef INCLUDE_xpm
-       if (strcmp (image_module->module_name, "xpm") == 0){
-               image_module->load           = mname (xpm,load);
-               image_module->load_xpm_data  = mname (xpm,load_xpm_data);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "tiff") == 0){
+                fill_vtable = mname (tiff, fill_vtable);
        }
 #endif
 
 #ifdef INCLUDE_xpm
-       if (strcmp (image_module->module_name, "xpm") == 0){
-               image_module->load           = mname (xpm,load);
-               image_module->load_xpm_data  = mname (xpm,load_xpm_data);
-               return TRUE;
+       else if (strcmp (image_module->module_name, "xpm") == 0){
+                fill_vtable = mname (xpm, fill_vtable);
        }
 #endif
 
-#ifdef INCLUDE_tiff
-       if (strcmp (image_module->module_name, "xbm") == 0){
-               image_module->load           = mname (xbm,load);
-               image_module->begin_load     = mname (xbm,begin_load);
-               image_module->load_increment = mname (xbm,load_increment);
-               image_module->stop_load      = mname (xbm,stop_load);
-               return TRUE;
+#ifdef INCLUDE_xbm
+       else if (strcmp (image_module->module_name, "xbm") == 0){
+                fill_vtable = mname (xbm, fill_vtable);
        }
 #endif
 
-        g_set_error (error,
-                     GDK_PIXBUF_ERROR,
-                     GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
-                     _("Image type '%s' is not supported"),
-                     image_module->module_name);
+        
+        if (fill_vtable) {
+                (* fill_vtable) (image_module);
+                return TRUE;
+        } else {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
+                             _("Image type '%s' is not supported"),
+                             image_module->module_name);
 
-        return FALSE;
+                return FALSE;
+        }
 }
 
 
index 60046b8e7fbb7b98dd7fc71ae8d457c84870add1..f271eca637b6f88d4861b89519e9297920a65887 100644 (file)
@@ -61,13 +61,14 @@ struct _GdkPixbufModule {
 
         /* Incremental loading */
 
-        gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
-                                ModuleUpdatedNotifyFunc update_func,
-                                ModuleFrameDoneNotifyFunc frame_done_func,
-                                ModuleAnimationDoneNotifyFunc anim_done_func,
-                                gpointer user_data,
-                                 GError **error);
-        void (* stop_load)          (gpointer context);
+        gpointer (* begin_load)     (ModulePreparedNotifyFunc prepare_func,
+                                     ModuleUpdatedNotifyFunc update_func,
+                                     ModuleFrameDoneNotifyFunc frame_done_func,
+                                     ModuleAnimationDoneNotifyFunc anim_done_func,
+                                     gpointer user_data,
+                                     GError **error);
+        gboolean (* stop_load)      (gpointer context,
+                                     GError **error);
         gboolean (* load_increment) (gpointer      context,
                                      const guchar *buf,
                                      guint         size,
@@ -84,6 +85,7 @@ struct _GdkPixbufModule {
                            GError   **error);
 };
 
+typedef void (* ModuleFillVtableFunc) (GdkPixbufModule *module);
 
 GdkPixbufModule *gdk_pixbuf_get_module (guchar *buffer, guint size,
                                         const gchar *filename,
index 60277caddd22fcd0c19d8e24b7228c9b160951f2..61d402eaf5de1c87ddac20538979866f39c66877 100644 (file)
@@ -28,8 +28,9 @@
 #include "gdk-pixbuf-private.h"
 #include "gdk-pixbuf-loader.h"
 #include "gdk-pixbuf-io.h"
+#include "gdk-pixbuf-marshal.h"
 
-#include "gtksignal.h"
+#include <gobject/gsignal.h>
 
 enum {
   AREA_UPDATED,
@@ -92,6 +93,8 @@ gdk_pixbuf_loader_get_type (void)
         0,              /* n_preallocs */
         (GInstanceInitFunc) gdk_pixbuf_loader_init
       };
+
+      g_type_init ();
       
       loader_type = g_type_register_static (G_TYPE_OBJECT,
                                             "GdkPixbufLoader",
@@ -119,7 +122,7 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_prepared),
                    NULL,
-                   gtk_marshal_VOID__VOID,
+                   gdk_pixbuf_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);
   
   pixbuf_loader_signals[AREA_UPDATED] =
@@ -128,7 +131,7 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_updated),
                    NULL,
-                   gtk_marshal_VOID__INT_INT_INT_INT,
+                   gdk_pixbuf_marshal_VOID__INT_INT_INT_INT,
                    G_TYPE_NONE, 4,
                    G_TYPE_INT,
                    G_TYPE_INT,
@@ -141,7 +144,7 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GdkPixbufLoaderClass, frame_done),
                    NULL,
-                   gtk_marshal_VOID__POINTER,
+                   gdk_pixbuf_marshal_VOID__POINTER,
                    G_TYPE_NONE, 1,
                    GDK_TYPE_PIXBUF_FRAME);
   
@@ -151,7 +154,7 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
                    G_SIGNAL_RUN_LAST,                   
                    G_STRUCT_OFFSET (GdkPixbufLoaderClass, animation_done),
                    NULL,
-                   gtk_marshal_VOID__VOID,
+                   gdk_pixbuf_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);
   
   pixbuf_loader_signals[CLOSED] =
@@ -160,7 +163,7 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
                    G_SIGNAL_RUN_LAST,
                    G_STRUCT_OFFSET (GdkPixbufLoaderClass, closed),
                    NULL,
-                   gtk_marshal_VOID__VOID,
+                   gdk_pixbuf_marshal_VOID__VOID,
                    G_TYPE_NONE, 0);
 }
 
@@ -421,7 +424,7 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader,
  * and FALSE if an error occurred.  In the latter case, the loader
  * will be closed, and will not accept further writes. If FALSE is
  * returned, @error will be set to an error from the #GDK_PIXBUF_ERROR
- * domain.
+ * or #G_FILE_ERROR domains.
  *
  * Return value: #TRUE if the write was successful, or #FALSE if the loader
  * cannot parse the buffer.
@@ -595,31 +598,46 @@ gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader)
 /**
  * gdk_pixbuf_loader_close:
  * @loader: A pixbuf loader.
+ * @error: return location for a #GError, or %NULL to ignore errors
+ *
+ * Informs a pixbuf loader that no further writes with
+ * gdk_pixbuf_loader_write() will occur, so that it can free its
+ * internal loading structures. Also, tries to parse any data that
+ * hasn't yet been parsed; if the remaining data is partial or
+ * corrupt, an error will be returned.  If FALSE is returned, @error
+ * will be set to an error from the #GDK_PIXBUF_ERROR or #G_FILE_ERROR
+ * domains. If you're just cancelling a load rather than expecting it
+ * to be finished, passing %NULL for @error to ignore it is
+ * reasonable.
  *
- * Informs a pixbuf loader that no further writes with gdk_pixbuf_loader_write()
- * will occur, so that it can free its internal loading structures.
+ * Returns: %TRUE if all image data written so far was successfully
+            passed out via the update_area signal
  **/
-void
-gdk_pixbuf_loader_close (GdkPixbufLoader *loader)
+gboolean
+gdk_pixbuf_loader_close (GdkPixbufLoader *loader,
+                         GError         **error)
 {
   GdkPixbufLoaderPrivate *priv;
+  gboolean retval = TRUE;
   
-  g_return_if_fail (loader != NULL);
-  g_return_if_fail (GDK_IS_PIXBUF_LOADER (loader));
+  g_return_val_if_fail (loader != NULL, TRUE);
+  g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), TRUE);
   
   priv = loader->private;
   
   /* we expect it's not closed */
-  g_return_if_fail (priv->closed == FALSE);
+  g_return_val_if_fail (priv->closed == FALSE, TRUE);
   
   /* We have less the 128 bytes in the image.  Flush it, and keep going. */
   if (priv->image_module == NULL)
     gdk_pixbuf_loader_load_module (loader, NULL, NULL);
   
   if (priv->image_module && priv->image_module->stop_load)
-    priv->image_module->stop_load (priv->context);
+    retval = priv->image_module->stop_load (priv->context, error);
   
   priv->closed = TRUE;
   
   g_signal_emit (G_OBJECT (loader), pixbuf_loader_signals[CLOSED], 0);
+
+  return retval;
 }
index 01532ad782b7ecc75deb42c904ba0b40581a85aa..a2479aae1a7dfa50d2a391f5538558eb60f29bac 100644 (file)
@@ -26,8 +26,6 @@
 #ifndef GDK_PIXBUF_LOADER_H
 #define GDK_PIXBUF_LOADER_H
 
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -77,7 +75,8 @@ gboolean             gdk_pixbuf_loader_write         (GdkPixbufLoader *loader,
                                                       GError         **error);
 GdkPixbuf *          gdk_pixbuf_loader_get_pixbuf    (GdkPixbufLoader *loader);
 GdkPixbufAnimation * gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader);
-void                 gdk_pixbuf_loader_close         (GdkPixbufLoader *loader);
+gboolean             gdk_pixbuf_loader_close         (GdkPixbufLoader *loader,
+                                                      GError         **error);
 
 
 #ifdef __cplusplus
diff --git a/gdk-pixbuf/gdk-pixbuf-marshal.list b/gdk-pixbuf/gdk-pixbuf-marshal.list
new file mode 100644 (file)
index 0000000..79a99c7
--- /dev/null
@@ -0,0 +1,26 @@
+# see glib-genmarshal(1) for a detailed description of the file format,
+# possible parameter types are:
+#   VOID        indicates   no   return   type,  or  no  extra
+#               parameters. if VOID is used as  the  parameter
+#               list, no additional parameters may be present.
+#   BOOLEAN     for boolean types (gboolean)
+#   CHAR        for signed char types (gchar)
+#   UCHAR       for unsigned char types (guchar)
+#   INT         for signed integer types (gint)
+#   UINT        for unsigned integer types (guint)
+#   LONG        for signed long integer types (glong)
+#   ULONG       for unsigned long integer types (gulong)
+#   ENUM        for enumeration types (gint)
+#   FLAGS       for flag enumeration types (guint)
+#   FLOAT       for single-precision float types (gfloat)
+#   DOUBLE      for double-precision float types (gdouble)
+#   STRING      for string types (gchar*)
+#   BOXED       for boxed (anonymous but reference counted) types (GBoxed*)
+#   POINTER     for anonymous pointer types (gpointer)
+#   OBJECT      for GObject or derived types (GObject*)
+#   NONE        deprecated alias for VOID
+#   BOOL        deprecated alias for BOOLEAN
+
+VOID:VOID
+VOID:INT,INT,INT,INT
+VOID:POINTER
index b2e3f53969dcd411a4329a70bfb16c6e3bc8b90b..56d364cf4749ffc04c8a671cb8db2c9b1c5d7499 100644 (file)
@@ -54,6 +54,8 @@ gdk_pixbuf_get_type (void)
                         (GInstanceInitFunc) NULL,
                 };
       
+                g_type_init ();
+                
                 object_type = g_type_register_static (G_TYPE_OBJECT,
                                                       "GdkPixbuf",
                                                       &object_info, 0);
@@ -398,24 +400,6 @@ const guint gdk_pixbuf_micro_version = GDK_PIXBUF_MICRO;
 
 const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
 
-void
-gdk_pixbuf_preinit (gpointer app, gpointer modinfo)
-{
-        g_type_init ();
-}
-
-void
-gdk_pixbuf_postinit (gpointer app, gpointer modinfo)
-{
-}
-
-void
-gdk_pixbuf_init (void)
-{
-        gdk_pixbuf_preinit (NULL, NULL);
-        gdk_pixbuf_postinit (NULL, NULL);
-}
-
 /* Error quark */
 GQuark
 gdk_pixbuf_error_quark (void)
@@ -426,3 +410,7 @@ gdk_pixbuf_error_quark (void)
 
   return q;
 }
+
+/* Include the marshallers */
+#include <gobject/gvaluetypes.h>
+#include "gdk-pixbuf-marshal.c"
index 381bbc5387e85f9c8629b741ece5093d9845b9b5..b8ffb48f78aa934ef3d1de81ef628b0edabc9551 100644 (file)
@@ -284,12 +284,7 @@ void                 gdk_pixbuf_frame_free           (GdkPixbufFrame *frame);
 GType                gdk_pixbuf_frame_get_type       (void) G_GNUC_CONST;
 #define              GDK_TYPE_PIXBUF_FRAME gdk_pixbuf_frame_get_type ()
 
-
-/* General (presently empty) initialization hooks, primarily for gnome-libs */
-void gdk_pixbuf_preinit  (gpointer app, gpointer modinfo);
-void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
-/* A more user-friendly init function */
-void gdk_pixbuf_init     (void);
+#include <gdk-pixbuf/gdk-pixbuf-loader.h>
 
 \f
 
index b090957bebe6c3baecca4c3d3ddac138b3ebd8c2..c5108bcc1df49c8508d1ee31b5f23bb210d4a966 100644 (file)
@@ -171,7 +171,7 @@ struct bmp_progressive_state {
        GdkPixbuf *pixbuf;      /* Our "target" */
 };
 
-gpointer
+static gpointer
 gdk_pixbuf__bmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 ModuleUpdatedNotifyFunc updated_func,
                                 ModuleFrameDoneNotifyFunc frame_done_func,
@@ -179,16 +179,17 @@ gdk_pixbuf__bmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 anim_done_func, gpointer user_data,
                                  GError **error);
 
-void gdk_pixbuf__bmp_image_stop_load(gpointer data);
-gboolean gdk_pixbuf__bmp_image_load_increment(gpointer data, guchar * buf,
-                                             guint size,
-                                              GError **error);
+static gboolean gdk_pixbuf__bmp_image_stop_load(gpointer data, GError **error);
+static gboolean gdk_pixbuf__bmp_image_load_increment(gpointer data,
+                                                     const guchar * buf,
+                                                     guint size,
+                                                     GError **error);
 
 
 
 /* Shared library entry point --> This should be removed when
    generic_image_load enters gdk-pixbuf-io. */
-GdkPixbuf *gdk_pixbuf__bmp_image_load(FILE * f, GError **error)
+static GdkPixbuf *gdk_pixbuf__bmp_image_load(FILE * f, GError **error)
 {
        guchar membuf[4096];
        size_t length;
@@ -210,7 +211,7 @@ GdkPixbuf *gdk_pixbuf__bmp_image_load(FILE * f, GError **error)
                                                             membuf,
                                                             length,
                                                             error)) {
-                          gdk_pixbuf__bmp_image_stop_load (State);
+                          gdk_pixbuf__bmp_image_stop_load (State, NULL);
                           return NULL;
                   }
 
@@ -220,13 +221,18 @@ GdkPixbuf *gdk_pixbuf__bmp_image_load(FILE * f, GError **error)
 
        pb = State->pixbuf;
 
-       gdk_pixbuf__bmp_image_stop_load(State);
+       gdk_pixbuf__bmp_image_stop_load(State, NULL);
        return pb;
 }
 
-static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
-                        struct bmp_progressive_state *State)
+static gboolean DecodeHeader(unsigned char *BFH, unsigned char *BIH,
+                             struct bmp_progressive_state *State,
+                             GError **error)
 {
+        gboolean retval = TRUE;
+
+        /* FIXME this is totally unrobust against bogus image data. */
+        
 #if DUMPBIH
        DumpBIH(BIH);
 #endif
@@ -284,9 +290,6 @@ static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
        if (State->LineBuf == NULL)
                State->LineBuf = g_malloc(State->LineWidth);
 
-       g_assert(State->LineBuf != NULL);
-
-
        if (State->pixbuf == NULL) {
                if (State->Type == 32)
                        State->pixbuf =
@@ -299,12 +302,21 @@ static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
                                           (gint) State->Header.width,
                                           (gint) State->Header.height);
 
+                if (State->pixbuf == NULL) {
+                        g_set_error (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                     _("Not enough memory to load bitmap image"));
+                        retval = FALSE;
+                }
+                
                if (State->prepared_func != NULL)
                        /* Notify the client that we are ready to go */
                        (*State->prepared_func) (State->pixbuf, State->user_data);
 
        }
 
+        return retval;
 }
 
 /* 
@@ -313,7 +325,7 @@ static void DecodeHeader(unsigned char *BFH, unsigned char *BIH,
  * return context (opaque to user)
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__bmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 ModuleUpdatedNotifyFunc updated_func,
                                 ModuleFrameDoneNotifyFunc frame_done_func,
@@ -357,13 +369,16 @@ gdk_pixbuf__bmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void gdk_pixbuf__bmp_image_stop_load(gpointer data)
+static gboolean gdk_pixbuf__bmp_image_stop_load(gpointer data, GError **error)
 {
        struct bmp_progressive_state *context =
            (struct bmp_progressive_state *) data;
 
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */        
 
-       g_return_if_fail(context != NULL);
+       g_return_val_if_fail(context != NULL, TRUE);
 
        if (context->LineBuf != NULL)
                g_free(context->LineBuf);
@@ -377,6 +392,8 @@ void gdk_pixbuf__bmp_image_stop_load(gpointer data)
                gdk_pixbuf_unref(context->pixbuf);
 
        g_free(context);
+
+        return TRUE;
 }
 
 
@@ -555,8 +572,9 @@ static void OneLine(struct bmp_progressive_state *context)
 }
 
 /* DoCompressedByte handles 1 byte of incomming compressed data */
-void DoCompressedByte(struct bmp_progressive_state *context, guchar ** buf,
-                     gint * size)
+static void
+DoCompressedByte(struct bmp_progressive_state *context, guchar ** buf,
+                 gint * size)
 {
        gint BytesToCopy;
        switch (context->compr.phase) {
@@ -705,10 +723,11 @@ void DoCompressedByte(struct bmp_progressive_state *context, guchar ** buf,
  *
  * append image data onto inrecrementally built output image
  */
-gboolean gdk_pixbuf__bmp_image_load_increment(gpointer data,
-                                              guchar * buf,
-                                             guint size,
-                                              GError **error)
+static gboolean
+gdk_pixbuf__bmp_image_load_increment(gpointer data,
+                                     const guchar * buf,
+                                     guint size,
+                                     GError **error)
 {
        struct bmp_progressive_state *context =
            (struct bmp_progressive_state *) data;
@@ -759,11 +778,22 @@ gboolean gdk_pixbuf__bmp_image_load_increment(gpointer data,
                }
 
                if (context->HeaderDone >= 14 + 40)
-                       DecodeHeader(context->HeaderBuf,
-                                    context->HeaderBuf + 14, context);
+                        if (!DecodeHeader(context->HeaderBuf,
+                                          context->HeaderBuf + 14, context,
+                                          error))
+                                return FALSE;
 
 
        }
 
        return TRUE;
 }
+
+void
+gdk_pixbuf__bmp_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__bmp_image_load;
+  module->begin_load = gdk_pixbuf__bmp_image_begin_load;
+  module->stop_load = gdk_pixbuf__bmp_image_stop_load;
+  module->load_increment = gdk_pixbuf__bmp_image_load_increment;
+}
index e61f41fb879577a23a140fbff9d78618cd70e294..5be68023fca39605ef7b866c4ed5bf51978ea89c 100644 (file)
@@ -135,7 +135,7 @@ struct _GifContext
        ModuleFrameDoneNotifyFunc frame_done_func;
        ModuleAnimationDoneNotifyFunc anim_done_func;
        gpointer user_data;
-       guchar *buf;
+        guchar *buf;
        guint ptr;
        guint size;
        guint amount_needed;
@@ -1125,7 +1125,7 @@ new_context (void)
        return context;
 }
 /* Shared library entry point */
-GdkPixbuf *
+static GdkPixbuf *
 gdk_pixbuf__gif_image_load (FILE *file, GError **error)
 {
        GifContext *context;
@@ -1145,7 +1145,7 @@ gdk_pixbuf__gif_image_load (FILE *file, GError **error)
        return pixbuf;
 }
 
-gpointer
+static gpointer
 gdk_pixbuf__gif_image_begin_load (ModulePreparedNotifyFunc prepare_func,
                                  ModuleUpdatedNotifyFunc update_func,
                                  ModuleFrameDoneNotifyFunc frame_done_func,
@@ -1169,23 +1169,30 @@ gdk_pixbuf__gif_image_begin_load (ModulePreparedNotifyFunc prepare_func,
        return (gpointer) context;
 }
 
-void
-gdk_pixbuf__gif_image_stop_load (gpointer data)
+static gboolean
+gdk_pixbuf__gif_image_stop_load (gpointer data, GError **error)
 {
        GifContext *context = (GifContext *) data;
 
        /* FIXME: free the animation data */
-
+        
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
+        
        if (context->pixbuf)
                gdk_pixbuf_unref (context->pixbuf);
        if (context->animation)
                gdk_pixbuf_animation_unref (context->animation);
 /*     g_free (context->buf);*/
        g_free (context);
+
+        return TRUE;
 }
 
-gboolean
-gdk_pixbuf__gif_image_load_increment (gpointer data, guchar *buf, guint size,
+static gboolean
+gdk_pixbuf__gif_image_load_increment (gpointer data,
+                                      const guchar *buf, guint size,
                                       GError **error)
 {
        gint retval;
@@ -1197,7 +1204,7 @@ gdk_pixbuf__gif_image_load_increment (gpointer data, guchar *buf, guint size,
                /* we aren't looking for some bytes. */
                /* we can use buf now, but we don't want to keep it around at all.
                 * it will be gone by the end of the call. */
-               context->buf = buf;
+               context->buf = (guchar*) buf; /* very dubious const cast */
                context->ptr = 0;
                context->size = size;
        } else {
@@ -1245,7 +1252,7 @@ gdk_pixbuf__gif_image_load_increment (gpointer data, guchar *buf, guint size,
        return TRUE;
 }
 
-GdkPixbufAnimation *
+static GdkPixbufAnimation *
 gdk_pixbuf__gif_image_load_animation (FILE *file,
                                       GError **error)
 {
@@ -1272,3 +1279,13 @@ gdk_pixbuf__gif_image_load_animation (FILE *file,
        g_free (context);
        return animation;
 }
+
+void
+gdk_pixbuf__gif_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__gif_image_load;
+  module->begin_load = gdk_pixbuf__gif_image_begin_load;
+  module->stop_load = gdk_pixbuf__gif_image_stop_load;
+  module->load_increment = gdk_pixbuf__gif_image_load_increment;
+  module->load_animation = gdk_pixbuf__gif_image_load_animation;
+}
index a85fee2806e19d46aa4cd0d7fb5d29e24f569a45..dc6dadb2f877c5a9dbd6c0e01436ac445d574cd7 100644 (file)
@@ -153,22 +153,23 @@ struct ico_progressive_state {
        GdkPixbuf *pixbuf;      /* Our "target" */
 };
 
-gpointer
+static gpointer
 gdk_pixbuf__ico_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 ModuleUpdatedNotifyFunc updated_func,
                                 ModuleFrameDoneNotifyFunc frame_done_func,
                                 ModuleAnimationDoneNotifyFunc anim_done_func,
                                 gpointer user_data,
                                  GError **error);
-void gdk_pixbuf__ico_image_stop_load(gpointer data);
-gboolean gdk_pixbuf__ico_image_load_increment(gpointer data, guchar * buf, guint size,
-                                              GError **error);
+static gboolean gdk_pixbuf__ico_image_stop_load(gpointer data, GError **error);
+static gboolean gdk_pixbuf__ico_image_load_increment(gpointer data,
+                                                     const guchar * buf, guint size,
+                                                     GError **error);
 
 
 
 /* Shared library entry point --> Can go when generic_image_load
    enters gdk-pixbuf-io */
-GdkPixbuf *
+static GdkPixbuf *
 gdk_pixbuf__ico_image_load(FILE * f, GError **error)
 {
        guchar *membuf;
@@ -191,7 +192,7 @@ gdk_pixbuf__ico_image_load(FILE * f, GError **error)
                if (length > 0)
                         if (!gdk_pixbuf__ico_image_load_increment(State, membuf, length,
                                                                   error)) {
-                                gdk_pixbuf__ico_image_stop_load (State);
+                                gdk_pixbuf__ico_image_stop_load (State, NULL);
                                 return NULL;
                         }
        }
@@ -201,7 +202,7 @@ gdk_pixbuf__ico_image_load(FILE * f, GError **error)
 
        pb = State->pixbuf;
 
-       gdk_pixbuf__ico_image_stop_load(State);
+       gdk_pixbuf__ico_image_stop_load(State, NULL);
        return pb;
 }
 
@@ -374,7 +375,7 @@ static void DecodeHeader(guchar *Data, gint Bytes,
  * return context (opaque to user)
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__ico_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 ModuleUpdatedNotifyFunc updated_func,
                                 ModuleFrameDoneNotifyFunc frame_done_func,
@@ -416,13 +417,17 @@ gdk_pixbuf__ico_image_begin_load(ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void gdk_pixbuf__ico_image_stop_load(gpointer data)
+gboolean gdk_pixbuf__ico_image_stop_load(gpointer data,
+                                         GError **error)
 {
        struct ico_progressive_state *context =
            (struct ico_progressive_state *) data;
 
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
 
-       g_return_if_fail(context != NULL);
+       g_return_val_if_fail(context != NULL, TRUE);
 
        if (context->LineBuf != NULL)
                g_free(context->LineBuf);
@@ -434,6 +439,8 @@ void gdk_pixbuf__ico_image_stop_load(gpointer data)
                gdk_pixbuf_unref(context->pixbuf);
 
        g_free(context);
+
+        return TRUE;
 }
 
 
@@ -642,8 +649,10 @@ static void OneLine(struct ico_progressive_state *context)
  *
  * append image data onto inrecrementally built output image
  */
-gboolean
-gdk_pixbuf__ico_image_load_increment(gpointer data, guchar * buf, guint size,
+static gboolean
+gdk_pixbuf__ico_image_load_increment(gpointer data,
+                                     const guchar * buf,
+                                     guint size,
                                      GError **error)
 {
        struct ico_progressive_state *context =
@@ -699,3 +708,12 @@ gdk_pixbuf__ico_image_load_increment(gpointer data, guchar * buf, guint size,
 
        return TRUE;
 }
+
+void
+gdk_pixbuf__ico_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__ico_image_load;
+  module->begin_load = gdk_pixbuf__ico_image_begin_load;
+  module->stop_load = gdk_pixbuf__ico_image_stop_load;
+  module->load_increment = gdk_pixbuf__ico_image_load_increment;
+}
index 332de30c999edcae715329e37bcd49780abd46a3..de40d2e786232027850c7619fab2b9d2ea2908d1 100644 (file)
@@ -93,16 +93,17 @@ typedef struct {
        struct error_handler_data     jerr;
 } JpegProgContext;
 
-GdkPixbuf *gdk_pixbuf__jpeg_image_load (FILE *f, GError **error);
-gpointer gdk_pixbuf__jpeg_image_begin_load (ModulePreparedNotifyFunc func, 
-                                           ModuleUpdatedNotifyFunc func2,
-                                           ModuleFrameDoneNotifyFunc func3,
-                                           ModuleAnimationDoneNotifyFunc func4,
-                                           gpointer user_data,
-                                            GError **error);
-void gdk_pixbuf__jpeg_image_stop_load (gpointer context);
-gboolean gdk_pixbuf__jpeg_image_load_increment(gpointer context, guchar *buf, guint size,
-                                               GError **error);
+static GdkPixbuf *gdk_pixbuf__jpeg_image_load (FILE *f, GError **error);
+static gpointer gdk_pixbuf__jpeg_image_begin_load (ModulePreparedNotifyFunc func, 
+                                                   ModuleUpdatedNotifyFunc func2,
+                                                   ModuleFrameDoneNotifyFunc func3,
+                                                   ModuleAnimationDoneNotifyFunc func4,
+                                                   gpointer user_data,
+                                                   GError **error);
+static gboolean gdk_pixbuf__jpeg_image_stop_load (gpointer context, GError **error);
+static gboolean gdk_pixbuf__jpeg_image_load_increment(gpointer context,
+                                                      const guchar *buf, guint size,
+                                                      GError **error);
 
 
 static void
@@ -179,7 +180,7 @@ explode_gray_into_buf (struct jpeg_decompress_struct *cinfo,
 }
 
 /* Shared library entry point */
-GdkPixbuf *
+static GdkPixbuf *
 gdk_pixbuf__jpeg_image_load (FILE *f, GError **error)
 {
        gint w, h, i;
@@ -367,13 +368,17 @@ gdk_pixbuf__jpeg_image_begin_load (ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void
-gdk_pixbuf__jpeg_image_stop_load (gpointer data)
+static gboolean
+gdk_pixbuf__jpeg_image_stop_load (gpointer data, GError **error)
 {
        JpegProgContext *context = (JpegProgContext *) data;
 
-       g_return_if_fail (context != NULL);
+       g_return_val_if_fail (context != NULL, TRUE);
 
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
+        
        if (context->pixbuf)
                gdk_pixbuf_unref (context->pixbuf);
 
@@ -392,6 +397,8 @@ gdk_pixbuf__jpeg_image_stop_load (gpointer data)
        }
 
        g_free (context);
+
+        return TRUE;
 }
 
 
@@ -404,8 +411,9 @@ gdk_pixbuf__jpeg_image_stop_load (gpointer data)
  *
  * append image data onto inrecrementally built output image
  */
-gboolean
-gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size,
+static gboolean
+gdk_pixbuf__jpeg_image_load_increment (gpointer data,
+                                       const guchar *buf, guint size,
                                        GError **error)
 {
        JpegProgContext *context = (JpegProgContext *)data;
@@ -415,7 +423,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size,
        guint       last_bytes_left;
        guint       spinguard;
        gboolean    first;
-       guchar *bufhd;
+       const guchar *bufhd;
 
        g_return_val_if_fail (context != NULL, FALSE);
        g_return_val_if_fail (buf != NULL, FALSE);
@@ -519,8 +527,11 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size,
                                                         cinfo->image_height);
 
                        if (context->pixbuf == NULL) {
-                               /* Failed to allocate memory */
-                               g_error ("Couldn't allocate gdkpixbuf");
+                                g_set_error (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                             _("Couldn't allocate memory for loading JPEG file"));
+                                return FALSE;
                        }
 
                        /* Use pixbuf buffer to store decompressed data */
@@ -610,7 +621,7 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, guchar *buf, guint size,
        return TRUE;
 }
 
-gboolean
+static gboolean
 gdk_pixbuf__jpeg_image_save (FILE          *f, 
                              GdkPixbuf     *pixbuf, 
                              gchar        **keys,
@@ -733,3 +744,13 @@ gdk_pixbuf__jpeg_image_save (FILE          *f,
        free (buf);
        return TRUE;
 }
+
+void
+gdk_pixbuf__jpeg_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__jpeg_image_load;
+  module->begin_load = gdk_pixbuf__jpeg_image_begin_load;
+  module->stop_load = gdk_pixbuf__jpeg_image_stop_load;
+  module->load_increment = gdk_pixbuf__jpeg_image_load_increment;
+  module->save = gdk_pixbuf__jpeg_image_save;
+}
index 321956ebad590f3e0143eeaac78d4b08251e64ef..19ca6132bee1c92129d6f33a941d98c1106bf21b 100644 (file)
@@ -180,7 +180,7 @@ free_buffer (guchar *pixels, gpointer data)
 }
 
 /* Shared library entry point */
-GdkPixbuf *
+static GdkPixbuf *
 gdk_pixbuf__png_image_load (FILE *f, GError **error)
 {
        png_structp png_ptr;
@@ -321,7 +321,7 @@ struct _LoadContext {
         GError **error;
 };
 
-gpointer
+static gpointer
 gdk_pixbuf__png_image_begin_load (ModulePreparedNotifyFunc prepare_func,
                                  ModuleUpdatedNotifyFunc update_func,
                                  ModuleFrameDoneNotifyFunc frame_done_func,
@@ -394,21 +394,28 @@ gdk_pixbuf__png_image_begin_load (ModulePreparedNotifyFunc prepare_func,
         return lc;
 }
 
-void
-gdk_pixbuf__png_image_stop_load (gpointer context)
+static gboolean
+gdk_pixbuf__png_image_stop_load (gpointer context, GError **error)
 {
         LoadContext* lc = context;
 
-        g_return_if_fail(lc != NULL);
+        g_return_val_if_fail(lc != NULL, TRUE);
 
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
+        
         gdk_pixbuf_unref(lc->pixbuf);
         
         png_destroy_read_struct(&lc->png_read_ptr, NULL, NULL);
         g_free(lc);
+
+        return TRUE;
 }
 
-gboolean
-gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size,
+static gboolean
+gdk_pixbuf__png_image_load_increment(gpointer context,
+                                     const guchar *buf, guint size,
                                      GError **error)
 {
         LoadContext* lc = context;
@@ -428,7 +435,8 @@ gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size,
                 lc->error = NULL;
                return FALSE;
        } else {
-               png_process_data(lc->png_read_ptr, lc->png_info_ptr, buf, size);
+               png_process_data(lc->png_read_ptr, lc->png_info_ptr,
+                                 (guchar*) buf, size);
        }
 
         if (lc->fatal_error_occurred) {
@@ -621,7 +629,7 @@ png_warning_callback(png_structp png_read_ptr,
 
 /* Save */
 
-gboolean
+static gboolean
 gdk_pixbuf__png_image_save (FILE          *f, 
                             GdkPixbuf     *pixbuf, 
                             gchar        **keys,
@@ -743,3 +751,12 @@ gdk_pixbuf__png_image_save (FILE          *f,
 
 
 
+void
+gdk_pixbuf__png_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__png_image_load;
+  module->begin_load = gdk_pixbuf__png_image_begin_load;
+  module->stop_load = gdk_pixbuf__png_image_stop_load;
+  module->load_increment = gdk_pixbuf__png_image_load_increment;
+  module->save = gdk_pixbuf__png_image_save;
+}
index c352d611f858b3cc3835f3e5c9c32a3a1dbdbba7..87c392db5a44bf737422bb1e0f018843a592b6ac 100644 (file)
@@ -81,16 +81,17 @@ typedef struct {
        
 } PnmLoaderContext;
 
-GdkPixbuf   *gdk_pixbuf__pnm_image_load          (FILE *f, GError **error);
-gpointer    gdk_pixbuf__pnm_image_begin_load     (ModulePreparedNotifyFunc func, 
-                                                 ModuleUpdatedNotifyFunc func2,
-                                                 ModuleFrameDoneNotifyFunc frame_done_func,
-                                                 ModuleAnimationDoneNotifyFunc anim_done_func,
-                                                 gpointer user_data,
-                                                 GError **error);
-void        gdk_pixbuf__pnm_image_stop_load      (gpointer context);
-gboolean    gdk_pixbuf__pnm_image_load_increment (gpointer context, guchar *buf, guint size,
-                                                 GError **error);
+static GdkPixbuf   *gdk_pixbuf__pnm_image_load          (FILE *f, GError **error);
+static gpointer    gdk_pixbuf__pnm_image_begin_load     (ModulePreparedNotifyFunc func, 
+                                                        ModuleUpdatedNotifyFunc func2,
+                                                        ModuleFrameDoneNotifyFunc frame_done_func,
+                                                        ModuleAnimationDoneNotifyFunc anim_done_func,
+                                                        gpointer user_data,
+                                                        GError **error);
+static gboolean    gdk_pixbuf__pnm_image_stop_load      (gpointer context, GError **error);
+static gboolean    gdk_pixbuf__pnm_image_load_increment (gpointer context,
+                                                        const guchar *buf, guint size,
+                                                        GError **error);
 
 static void explode_bitmap_into_buf              (PnmLoaderContext *context);
 static void explode_gray_into_buf                (PnmLoaderContext *context);
@@ -644,7 +645,7 @@ pnm_read_scanline (PnmLoaderContext *context)
 }
 
 /* Shared library entry point */
-GdkPixbuf *
+static GdkPixbuf *
 gdk_pixbuf__pnm_image_load (FILE *f, GError **error)
 {
        PnmLoaderContext context;
@@ -759,7 +760,7 @@ gdk_pixbuf__pnm_image_load (FILE *f, GError **error)
  * return context (opaque to user)
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__pnm_image_begin_load (ModulePreparedNotifyFunc prepared_func, 
                                  ModuleUpdatedNotifyFunc  updated_func,
                                  ModuleFrameDoneNotifyFunc frame_done_func,
@@ -795,17 +796,29 @@ gdk_pixbuf__pnm_image_begin_load (ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void
-gdk_pixbuf__pnm_image_stop_load (gpointer data)
+static gboolean
+gdk_pixbuf__pnm_image_stop_load (gpointer data,
+                                GError **error)
 {
        PnmLoaderContext *context = (PnmLoaderContext *) data;
+       gboolean retval = TRUE;
        
-       g_return_if_fail (context != NULL);
+       g_return_val_if_fail (context != NULL, TRUE);
        
        if (context->pixbuf)
                gdk_pixbuf_unref (context->pixbuf);
+
+       if (context->inbuf.nbytes > 0) {
+               g_set_error (error,
+                            GDK_PIXBUF_ERROR,
+                            GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                            _("Unexpected end of PNM image data"));
+               retval = FALSE;
+       }
        
        g_free (context);
+
+       return retval;
 }
 
 /*
@@ -815,8 +828,9 @@ gdk_pixbuf__pnm_image_stop_load (gpointer data)
  *
  * append image data onto inrecrementally built output image
  */
-gboolean
-gdk_pixbuf__pnm_image_load_increment (gpointer data, guchar *buf, guint size,
+static gboolean
+gdk_pixbuf__pnm_image_load_increment (gpointer data,
+                                     const guchar *buf, guint size,
                                      GError **error)
 {
        PnmLoaderContext *context = (PnmLoaderContext *)data;
@@ -897,8 +911,11 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, guchar *buf, guint size,
                                                          context->height);
                        
                        if (context->pixbuf == NULL) {
-                               /* Failed to allocate memory */
-                               g_error ("Couldn't allocate gdkpixbuf");
+                               g_set_error (error,
+                                            GDK_PIXBUF_ERROR,
+                                            GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                            _("Insufficient memory to load PNM file"));
+                               return FALSE;
                        }
                        
                        context->pixels = context->pixbuf->pixels;
@@ -938,3 +955,12 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, guchar *buf, guint size,
        
        return TRUE;
 }
+
+void
+gdk_pixbuf__pnm_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__pnm_image_load;
+  module->begin_load = gdk_pixbuf__pnm_image_begin_load;
+  module->stop_load = gdk_pixbuf__pnm_image_stop_load;
+  module->load_increment = gdk_pixbuf__pnm_image_load_increment;
+}
index dbcf7bc1494aeb34d008029b32ee0db23b8fbd7f..25a3c0b7a5b6f8c20d94ba1954666ef5c20f0456 100644 (file)
@@ -93,21 +93,22 @@ struct ras_progressive_state {
        GdkPixbuf *pixbuf;      /* Our "target" */
 };
 
-gpointer
+static gpointer
 gdk_pixbuf__ras_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 ModuleUpdatedNotifyFunc updated_func,
                                 ModuleFrameDoneNotifyFunc frame_done_func,
                                 ModuleAnimationDoneNotifyFunc anim_done_func,
                                 gpointer user_data,
                                  GError **error);
-void gdk_pixbuf__ras_image_stop_load(gpointer data);
-gboolean gdk_pixbuf__ras_image_load_increment(gpointer data, guchar * buf, guint size,
-                                              GError **error);
+static gboolean gdk_pixbuf__ras_image_stop_load(gpointer data, GError **error);
+static gboolean gdk_pixbuf__ras_image_load_increment(gpointer data,
+                                                     const guchar * buf, guint size,
+                                                     GError **error);
 
 
 
 /* Shared library entry point */
-GdkPixbuf *gdk_pixbuf__ras_image_load(FILE * f, GError **error)
+static GdkPixbuf *gdk_pixbuf__ras_image_load(FILE * f, GError **error)
 {
        guchar *membuf;
        size_t length;
@@ -126,7 +127,7 @@ GdkPixbuf *gdk_pixbuf__ras_image_load(FILE * f, GError **error)
                length = fread(membuf, 1, 4096, f);
                 if (!gdk_pixbuf__ras_image_load_increment(State, membuf, length,
                                                           error)) {
-                        gdk_pixbuf__ras_image_stop_load (State);
+                        gdk_pixbuf__ras_image_stop_load (State, NULL);
                         return NULL;
                 }
        }
@@ -136,7 +137,7 @@ GdkPixbuf *gdk_pixbuf__ras_image_load(FILE * f, GError **error)
 
        pb = State->pixbuf;
 
-       gdk_pixbuf__ras_image_stop_load(State);
+       gdk_pixbuf__ras_image_stop_load(State, NULL);
        return pb;
 }
 
@@ -215,7 +216,7 @@ static void RAS2State(struct rasterfile *RAS,
  * return context (opaque to user)
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__ras_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                 ModuleUpdatedNotifyFunc updated_func,
                                 ModuleFrameDoneNotifyFunc frame_done_func,
@@ -256,14 +257,17 @@ gdk_pixbuf__ras_image_begin_load(ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void
-gdk_pixbuf__ras_image_stop_load(gpointer data)
+static gboolean
+gdk_pixbuf__ras_image_stop_load(gpointer data, GError **error)
 {
        struct ras_progressive_state *context =
            (struct ras_progressive_state *) data;
 
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
 
-       g_return_if_fail(context != NULL);
+       g_return_val_if_fail(context != NULL, TRUE);
 
        if (context->LineBuf != NULL)
                g_free(context->LineBuf);
@@ -274,6 +278,8 @@ gdk_pixbuf__ras_image_stop_load(gpointer data)
                gdk_pixbuf_unref(context->pixbuf);
 
        g_free(context);
+
+        return TRUE;
 }
 
 /* 
@@ -392,8 +398,9 @@ static void OneLine(struct ras_progressive_state *context)
  *
  * append image data onto inrecrementally built output image
  */
-gboolean
-gdk_pixbuf__ras_image_load_increment(gpointer data, guchar * buf, guint size,
+static gboolean
+gdk_pixbuf__ras_image_load_increment(gpointer data,
+                                     const guchar * buf, guint size,
                                      GError **error)
 {
        struct ras_progressive_state *context =
@@ -448,3 +455,12 @@ gdk_pixbuf__ras_image_load_increment(gpointer data, guchar * buf, guint size,
 
        return TRUE;
 }
+
+void
+gdk_pixbuf__ras_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__ras_image_load;
+  module->begin_load = gdk_pixbuf__ras_image_begin_load;
+  module->stop_load = gdk_pixbuf__ras_image_stop_load;
+  module->load_increment = gdk_pixbuf__ras_image_load_increment;
+}
index 08fe3bc4af0e0e32386c688ce4f0e223ce96e3eb..9b23f5d719442364413a4f92bd607e00435d9c3a 100644 (file)
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #endif
 #include <tiffio.h>
+#include <errno.h>
 #include "gdk-pixbuf-private.h"
 #include "gdk-pixbuf-io.h"
 
@@ -55,8 +56,8 @@ struct _TiffData
 
 \f
 
-GdkPixbuf *
-gdk_pixbuf__tiff_image_load_real (FILE *f, TiffData *context)
+static GdkPixbuf *
+gdk_pixbuf__tiff_image_load_real (FILE *f, TiffData *context, GError **error)
 {
        TIFF *tiff;
        guchar *pixels = NULL;
@@ -68,14 +69,28 @@ gdk_pixbuf__tiff_image_load_real (FILE *f, TiffData *context)
        fd = fileno (f);
        tiff = TIFFFdOpen (fd, "libpixbuf-tiff", "r");
 
-       if (!tiff)
+       if (!tiff) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("Failed to open TIFF image"));
                return NULL;
-
+        }
+                
        TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &w);
        TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &h);
        num_pixs = w * h;
        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
 
+        if (!pixbuf) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                             _("Insufficient memory to open TIFF file"));
+               TIFFClose (tiff);
+               return NULL;
+        }
+        
        if (context)
                (* context->prepare_func) (pixbuf, context->user_data);
 
@@ -83,17 +98,19 @@ gdk_pixbuf__tiff_image_load_real (FILE *f, TiffData *context)
        rast = (uint32 *) _TIFFmalloc (num_pixs * sizeof (uint32));
 
        if (!rast) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                             _("Insufficient memory to open TIFF file"));
                TIFFClose (tiff);
                return NULL;
        }
 
        if (TIFFReadRGBAImage (tiff, w, h, rast, 0)) {
                pixels = gdk_pixbuf_get_pixels (pixbuf);
-               if (!pixels) {
-                       _TIFFfree (rast);
-                       TIFFClose (tiff);
-                       return NULL;
-               }
+
+                g_assert (pixels);
+                
                tmppix = pixels;
 
                for (y = 0; y < h; y++) {
@@ -128,10 +145,10 @@ gdk_pixbuf__tiff_image_load_real (FILE *f, TiffData *context)
 
 /* Static loader */
 
-GdkPixbuf *
-gdk_pixbuf__tiff_image_load (FILE *f)
+static GdkPixbuf *
+gdk_pixbuf__tiff_image_load (FILE *f, GError **error)
 {
-       return gdk_pixbuf__tiff_image_load_real (f, NULL);
+       return gdk_pixbuf__tiff_image_load_real (f, NULL, error);
 }
 
 \f
@@ -143,7 +160,7 @@ gdk_pixbuf__tiff_image_load (FILE *f)
  */
 
 
-gpointer
+static gpointer
 gdk_pixbuf__tiff_image_begin_load (ModulePreparedNotifyFunc prepare_func,
                                   ModuleUpdatedNotifyFunc update_func,
                                   ModuleFrameDoneNotifyFunc frame_done_func,
@@ -176,26 +193,35 @@ gdk_pixbuf__tiff_image_begin_load (ModulePreparedNotifyFunc prepare_func,
        return context;
 }
 
-void
-gdk_pixbuf__tiff_image_stop_load (gpointer data)
+static gboolean
+gdk_pixbuf__tiff_image_stop_load (gpointer data,
+                                  GError **error)
 {
        TiffData *context = (TiffData*) data;
-
-       g_return_if_fail (data != NULL);
+        gboolean retval = FALSE;
+        
+       g_return_val_if_fail (data != NULL, TRUE);
 
        fflush (context->file);
        rewind (context->file);
-       if (context->all_okay)
-               gdk_pixbuf__tiff_image_load_real (context->file, context);
+       if (context->all_okay) {
+                GdkPixbuf *pixbuf;
+               pixbuf = gdk_pixbuf__tiff_image_load_real (context->file, context, error);
+                if (pixbuf != NULL)
+                        retval = TRUE;
+        }
 
        fclose (context->file);
        unlink (context->tempname);
        g_free (context->tempname);
        g_free ((TiffData *) context);
+
+        return TRUE;
 }
 
-gboolean
-gdk_pixbuf__tiff_image_load_increment (gpointer data, guchar *buf, guint size)
+static gboolean
+gdk_pixbuf__tiff_image_load_increment (gpointer data, const guchar *buf,
+                                       guint size, GError **error)
 {
        TiffData *context = (TiffData *) data;
 
@@ -203,9 +229,22 @@ gdk_pixbuf__tiff_image_load_increment (gpointer data, guchar *buf, guint size)
 
        if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
                context->all_okay = FALSE;
+                g_set_error (error,
+                             G_FILE_ERROR,
+                             g_file_error_from_errno (errno),
+                             _("Failed to write to temporary file when loading TIFF image"));
                return FALSE;
        }
 
        return TRUE;
 }
 
+void
+gdk_pixbuf__tiff_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__tiff_image_load;
+  module->begin_load = gdk_pixbuf__tiff_image_begin_load;
+  module->stop_load = gdk_pixbuf__tiff_image_stop_load;
+  module->load_increment = gdk_pixbuf__tiff_image_load_increment;
+}
+
index bbca3e1a1739198ecbc8035d4647c9d8bb0d719b..1b7784b13d81c08929432248c78b1e65a8575b45 100644 (file)
@@ -62,7 +62,7 @@ struct wbmp_progressive_state {
   GdkPixbuf *pixbuf;   /* Our "target" */
 };
 
-gpointer
+static gpointer
 gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                  ModuleUpdatedNotifyFunc updated_func,
                                  ModuleFrameDoneNotifyFunc frame_done_func,
@@ -70,15 +70,16 @@ gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                  anim_done_func, gpointer user_data,
                                   GError **error);
 
-void gdk_pixbuf__wbmp_image_stop_load(gpointer data);
-gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
-                                              guint size,
-                                               GError **error);
+static gboolean gdk_pixbuf__wbmp_image_stop_load(gpointer data, GError **error);
+static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data,
+                                                      const guchar * buf,
+                                                      guint size,
+                                                      GError **error);
 
 
 /* Shared library entry point --> This should be removed when
    generic_image_load enters gdk-pixbuf-io. */
-GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f, GError **error)
+static GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f, GError **error)
 {
        size_t length;
        char membuf[4096];
@@ -106,7 +107,7 @@ GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f, GError **error)
 
        pb = State->pixbuf;
 
-       gdk_pixbuf__wbmp_image_stop_load(State);
+       gdk_pixbuf__wbmp_image_stop_load(State, NULL);
        return pb;
 }
 
@@ -116,7 +117,7 @@ GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f, GError **error)
  * return context (opaque to user)
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
                                   ModuleUpdatedNotifyFunc updated_func,
                                   ModuleFrameDoneNotifyFunc frame_done_func,
@@ -143,16 +144,23 @@ gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
  *
  * free context, unref gdk_pixbuf
  */
-void gdk_pixbuf__wbmp_image_stop_load(gpointer data)
+static gboolean gdk_pixbuf__wbmp_image_stop_load(gpointer data,
+                                                 GError **error)
 {
        struct wbmp_progressive_state *context =
            (struct wbmp_progressive_state *) data;
 
-       g_return_if_fail(context != NULL);
+        /* FIXME this thing needs to report errors if
+         * we have unused image data
+         */
+        
+       g_return_val_if_fail(context != NULL, TRUE);
        if (context->pixbuf)
          gdk_pixbuf_unref(context->pixbuf);
 
        g_free(context);
+
+        return TRUE;
 }
 
 static gboolean
@@ -228,8 +236,9 @@ get_mbi(struct wbmp_progressive_state *context, guchar **buf, guint *buf_size, i
  *
  * append image data onto inrecrementally built output image
  */
-gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
-                                               guint size, GError **error)
+static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data,
+                                                      const guchar * buf,
+                                                      guint size, GError **error)
 {
        struct wbmp_progressive_state *context =
            (struct wbmp_progressive_state *) data;
@@ -324,3 +333,12 @@ gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
        else
          return context->needmore;
 }
+
+void
+gdk_pixbuf__wbmp_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__wbmp_image_load;
+  module->begin_load = gdk_pixbuf__wbmp_image_begin_load;
+  module->stop_load = gdk_pixbuf__wbmp_image_stop_load;
+  module->load_increment = gdk_pixbuf__wbmp_image_load_increment;
+}
index affa148fff75e9342ae02cf94ac29e0e4a1f93a7..05d8f994a49a4421d293d6b76eaee2eec00bccfb 100644 (file)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <errno.h>
 #include "gdk-pixbuf-private.h"
 #include "gdk-pixbuf-io.h"
 
@@ -262,8 +263,8 @@ read_bitmap_file_data (FILE *fstream,
 
 \f
 
-GdkPixbuf *
-gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context)
+static GdkPixbuf *
+gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
 {
        guint w, h;
        int x_hot, y_hot;
@@ -277,11 +278,24 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context)
        GdkPixbuf *pixbuf;
 
        if (!read_bitmap_file_data (f, &w, &h, &data, &x_hot, &y_hot)) {
-               g_message ("Invalid XBM file: %s", context->tempname);
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("Invalid XBM file: %s"),
+                             context->tempname);
                return NULL;
        }
 
        pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, w, h);
+
+        if (pixbuf == NULL) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                             _("Insufficient memory to load XBM image file"));
+                return NULL;
+        }
+        
        pixels = gdk_pixbuf_get_pixels (pixbuf);
        row_stride = gdk_pixbuf_get_rowstride (pixbuf);
 
@@ -324,10 +338,10 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context)
 \f
 /* Static loader */
 
-GdkPixbuf *
-gdk_pixbuf__xbm_image_load (FILE *f)
+static GdkPixbuf *
+gdk_pixbuf__xbm_image_load (FILE *f, GError **error)
 {
-       return gdk_pixbuf__xbm_image_load_real (f, NULL);
+       return gdk_pixbuf__xbm_image_load_real (f, NULL, error);
 }
 
 \f
@@ -338,7 +352,7 @@ gdk_pixbuf__xbm_image_load (FILE *f)
  * it to a file, then load the file when it's done.  It's not pretty.
  */
 
-gpointer
+static gpointer
 gdk_pixbuf__xbm_image_begin_load (ModulePreparedNotifyFunc prepare_func,
                                  ModuleUpdatedNotifyFunc update_func,
                                  ModuleFrameDoneNotifyFunc frame_done_func,
@@ -372,26 +386,38 @@ gdk_pixbuf__xbm_image_begin_load (ModulePreparedNotifyFunc prepare_func,
        return context;
 }
 
-void
-gdk_pixbuf__xbm_image_stop_load (gpointer data)
+static gboolean
+gdk_pixbuf__xbm_image_stop_load (gpointer data,
+                                 GError **error)
 {
        XBMData *context = (XBMData*) data;
+        gboolean retval = TRUE;
 
-       g_return_if_fail (data != NULL);
+       g_return_val_if_fail (data != NULL, TRUE);
 
        fflush (context->file);
        rewind (context->file);
-       if (context->all_okay)
-               gdk_pixbuf__xbm_image_load_real (context->file, context);
+       if (context->all_okay) {
+                GdkPixbuf *pixbuf;
+                pixbuf = gdk_pixbuf__xbm_image_load_real (context->file, context,
+                                                          error);
+                if (pixbuf == NULL)
+                        retval = FALSE;
+        }
 
        fclose (context->file);
        unlink (context->tempname);
        g_free (context->tempname);
        g_free ((XBMData *) context);
+
+        return retval;
 }
 
-gboolean
-gdk_pixbuf__xbm_image_load_increment (gpointer data, guchar *buf, guint size)
+static gboolean
+gdk_pixbuf__xbm_image_load_increment (gpointer data,
+                                      const guchar  *buf,
+                                      guint    size,
+                                      GError **error)
 {
        XBMData *context = (XBMData *) data;
 
@@ -399,8 +425,21 @@ gdk_pixbuf__xbm_image_load_increment (gpointer data, guchar *buf, guint size)
 
        if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
                context->all_okay = FALSE;
+                g_set_error (error,
+                             G_FILE_ERROR,
+                             g_file_error_from_errno (errno),
+                             _("Failed to write to temporary file when loading XBM image"));
                return FALSE;
        }
 
        return TRUE;
 }
+
+void
+gdk_pixbuf__xbm_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__xbm_image_load;
+  module->begin_load = gdk_pixbuf__xbm_image_begin_load;
+  module->stop_load = gdk_pixbuf__xbm_image_stop_load;
+  module->load_increment = gdk_pixbuf__xbm_image_load_increment;
+}
index e813ae081c75610f1f49833a89165b923e45dae7..00cb7b93657636d3f2d4bc9491669c2876cdaa50 100644 (file)
@@ -30,6 +30,7 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h> /* for unlink */
 #endif
+#include <errno.h>
 #include "gdk-pixbuf-private.h"
 #include "gdk-pixbuf-io.h"
 
@@ -1233,7 +1234,8 @@ free_buffer (guchar *pixels, gpointer data)
 
 /* This function does all the work. */
 static GdkPixbuf *
-pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handle), gpointer handle)
+pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handle), gpointer handle,
+                        GError **error)
 {
        gint w, h, n_col, cpp;
        gint cnt, xcnt, ycnt, wbytes, n, ns;
@@ -1249,12 +1251,18 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
 
        buffer = (*get_buf) (op_header, handle);
        if (!buffer) {
-               g_warning ("No XPM header found");
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("No XPM header found"));
                return NULL;
        }
        sscanf (buffer, "%d %d %d %d", &w, &h, &n_col, &cpp);
        if (cpp >= 32) {
-               g_warning ("XPM has more than 31 chars per pixel.");
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("XPM has more than 31 chars per pixel"));
                return NULL;
        }
 
@@ -1269,7 +1277,10 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
 
                buffer = (*get_buf) (op_cmap, handle);
                if (!buffer) {
-                       g_warning ("Can't load XPM colormap");
+                        g_set_error (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                     _("Can't read XPM colormap"));
                        g_hash_table_destroy (color_hash);
                        g_free (name_buf);
                        g_free (colors);
@@ -1299,11 +1310,15 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
        }
 
        if (is_trans)
-               pixels = malloc (w * h * 4);
+               pixels = g_try_malloc (w * h * 4);
        else
-               pixels = malloc (w * h * 3);
+               pixels = g_try_malloc (w * h * 3);
 
        if (!pixels) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                             _("Can't allocate memory for loading XPM image"));
                g_hash_table_destroy (color_hash);
                g_free (colors);
                g_free (name_buf);
@@ -1350,31 +1365,39 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl
 }
 
 /* Shared library entry point for file loading */
-GdkPixbuf *
-gdk_pixbuf__xpm_image_load (FILE *f)
+static GdkPixbuf *
+gdk_pixbuf__xpm_image_load (FILE *f,
+                            GError **error)
 {
        GdkPixbuf *pixbuf;
        struct file_handle h;
 
        memset (&h, 0, sizeof (h));
        h.infile = f;
-       pixbuf = pixbuf_create_from_xpm (file_buffer, &h);
+       pixbuf = pixbuf_create_from_xpm (file_buffer, &h, error);
        g_free (h.buffer);
 
        return pixbuf;
 }
 
 /* Shared library entry point for memory loading */
-GdkPixbuf *
+static GdkPixbuf *
 gdk_pixbuf__xpm_image_load_xpm_data (const gchar **data)
 {
         GdkPixbuf *pixbuf;
         struct mem_handle h;
-
+        GError *error = NULL;
+        
         h.data = data;
         h.offset = 0;
         
-       pixbuf = pixbuf_create_from_xpm (mem_buffer, &h);
+       pixbuf = pixbuf_create_from_xpm (mem_buffer, &h, &error);
+
+        if (error) {
+                g_warning ("Inline XPM data is broken: %s", error->message);
+                g_error_free (error);
+                error = NULL;
+        }
         
        return pixbuf;
 }
@@ -1398,7 +1421,7 @@ struct _XPMContext
  * This is very broken but it should be relayively simple to fix
  * in the future.
  */
-gpointer
+static gpointer
 gdk_pixbuf__xpm_image_begin_load (ModulePreparedNotifyFunc prepare_func,
                                   ModuleUpdatedNotifyFunc update_func,
                                   ModuleFrameDoneNotifyFunc frame_done_func,
@@ -1432,43 +1455,66 @@ gdk_pixbuf__xpm_image_begin_load (ModulePreparedNotifyFunc prepare_func,
        return context;
 }
 
-void
-gdk_pixbuf__xpm_image_stop_load (gpointer data)
+static gboolean
+gdk_pixbuf__xpm_image_stop_load (gpointer data,
+                                 GError **error)
 {
        XPMContext *context = (XPMContext*) data;
        GdkPixbuf *pixbuf;
-
-       g_return_if_fail (data != NULL);
-       g_warning ("stopped loading");
+       gboolean retval = FALSE;
+       
+       g_return_val_if_fail (data != NULL, FALSE);
 
        fflush (context->file);
        rewind (context->file);
        if (context->all_okay) {
-               pixbuf = gdk_pixbuf__xpm_image_load (context->file);
+               pixbuf = gdk_pixbuf__xpm_image_load (context->file, error);
+
+               if (pixbuf != NULL) {
+                       (* context->prepare_func) (pixbuf, context->user_data);
+                       (* context->update_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data);
+                       gdk_pixbuf_unref (pixbuf);
 
-               (* context->prepare_func) (pixbuf, context->user_data);
-               (* context->update_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data);
-               gdk_pixbuf_unref (pixbuf);
+                       retval = TRUE;
+               }
        }
 
        fclose (context->file);
        unlink (context->tempname);
        g_free (context->tempname);
        g_free ((XPMContext *) context);
+
+       return retval;
 }
 
-gboolean
-gdk_pixbuf__xpm_image_load_increment (gpointer data, guchar *buf, guint size)
+static gboolean
+gdk_pixbuf__xpm_image_load_increment (gpointer data,
+                                      const guchar *buf,
+                                      guint    size,
+                                      GError **error)
 {
        XPMContext *context = (XPMContext *) data;
 
        g_return_val_if_fail (data != NULL, FALSE);
-       g_warning ("load increment");
 
        if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
                context->all_okay = FALSE;
+               g_set_error (error,
+                            G_FILE_ERROR,
+                            g_file_error_from_errno (errno),
+                            _("Failed to write to temporary file when loading XPM image"));
                return FALSE;
        }
 
        return TRUE;
 }
+
+void
+gdk_pixbuf__xpm_fill_vtable (GdkPixbufModule *module)
+{
+  module->load = gdk_pixbuf__xpm_image_load;
+  module->load_xpm_data = gdk_pixbuf__xpm_image_load_xpm_data;
+  module->begin_load = gdk_pixbuf__xpm_image_begin_load;
+  module->stop_load = gdk_pixbuf__xpm_image_stop_load;
+  module->load_increment = gdk_pixbuf__xpm_image_load_increment;
+}
index 445fbd88a9a634f687d9091654ec93938662baff..2b44ba62b916535ce0a4cb7f0e5d5f5a826db5fe 100644 (file)
@@ -152,8 +152,6 @@ main (int argc, char **argv)
   FILE *outfile;
   int i;
   
-  gdk_pixbuf_init ();
-  
   if (argc < 4)
     usage ();
 
index f777fb89cdc215188240f10828587899c29de494..03c681dec52e9d8cab1167ff6ac4e6b438f11660 100644 (file)
@@ -49,4 +49,5 @@ _pixops_have_mmx:
        movl    $0, %eax
 .out:  
        popl    %ebx
-       ret
\ No newline at end of file
+       ret
+
index b4110731ddf43b133a21d9aa51f69d79a07f9282..4f6f51cc5b057eb8fe9318eaee8de7df8ea5a0c5 100644 (file)
@@ -228,8 +228,6 @@ main (int argc, char **argv)
        int result;
 
        result = EXIT_SUCCESS;
-
-       gdk_pixbuf_init ();
        
        /* Run some tests. */
        if (!simple_composite_test ()) {
index b8d296f9976d4059b125d126cdf82c2b418f47af..bdd2659b576565febedae1ad3dbb6d647ce5a1a3 100644 (file)
@@ -131,7 +131,6 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
        gtkoptionmenu.h         \
        gtkpacker.h             \
        gtkpaned.h              \
-       gdk-pixbuf-loader.h     \
        gtkpixmap.h             \
        gtkplug.h               \
        gtkpreview.h            \
@@ -357,7 +356,6 @@ gtk_c_sources = @STRIP_BEGIN@   \
        gtkwindow-decorate.c    \
        fnmatch.c               \
        fnmatch.h               \
-       gdk-pixbuf-loader.c     \
 @STRIP_END@
 # Extra headers that are used for enum type array/id generation
 gdk_headers = @STRIP_BEGIN@    \
diff --git a/gtk/gdk-pixbuf-loader.c b/gtk/gdk-pixbuf-loader.c
deleted file mode 100644 (file)
index 60277ca..0000000
+++ /dev/null
@@ -1,625 +0,0 @@
-/* GdkPixbuf library - Progressive loader object
- *
- * Copyright (C) 1999 The Free Software Foundation
- *
- * Authors: Mark Crichton <crichton@gimp.org>
- *          Miguel de Icaza <miguel@gnu.org>
- *          Federico Mena-Quintero <federico@gimp.org>
- *          Jonathan Blandford <jrb@redhat.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-
-#include "gdk-pixbuf-private.h"
-#include "gdk-pixbuf-loader.h"
-#include "gdk-pixbuf-io.h"
-
-#include "gtksignal.h"
-
-enum {
-  AREA_UPDATED,
-  AREA_PREPARED,
-  FRAME_DONE,
-  ANIMATION_DONE,
-  CLOSED,
-  LAST_SIGNAL
-};
-
-
-static void gdk_pixbuf_loader_class_init    (GdkPixbufLoaderClass   *klass);
-static void gdk_pixbuf_loader_init          (GdkPixbufLoader        *loader);
-static void gdk_pixbuf_loader_finalize      (GObject                *loader);
-
-static gpointer parent_class = NULL;
-static guint    pixbuf_loader_signals[LAST_SIGNAL] = { 0 };
-
-
-/* Internal data */
-
-#define LOADER_HEADER_SIZE 128
-
-typedef struct
-{
-  GdkPixbuf *pixbuf;
-  GdkPixbufAnimation *animation;
-  gboolean closed;
-  guchar header_buf[LOADER_HEADER_SIZE];
-  gint header_buf_offset;
-  GdkPixbufModule *image_module;
-  gpointer context;
-} GdkPixbufLoaderPrivate;
-
-
-/**
- * gdk_pixbuf_loader_get_type:
- * @void:
- *
- * Registers the #GdkPixubfLoader class if necessary, and returns the type ID
- * associated to it.
- *
- * Return value: The type ID of the #GdkPixbufLoader class.
- **/
-GType
-gdk_pixbuf_loader_get_type (void)
-{
-  static GType loader_type = 0;
-  
-  if (!loader_type)
-    {
-      static const GTypeInfo loader_info = {
-        sizeof (GdkPixbufLoaderClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) gdk_pixbuf_loader_class_init,
-        NULL,           /* class_finalize */
-        NULL,           /* class_data */
-        sizeof (GdkPixbufLoader),
-        0,              /* n_preallocs */
-        (GInstanceInitFunc) gdk_pixbuf_loader_init
-      };
-      
-      loader_type = g_type_register_static (G_TYPE_OBJECT,
-                                            "GdkPixbufLoader",
-                                            &loader_info,
-                                            0);
-    }
-  
-  return loader_type;
-}
-
-static void
-gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
-{
-  GObjectClass *object_class;
-  
-  object_class = (GObjectClass *) class;
-  
-  parent_class = g_type_class_peek_parent (class);
-  
-  object_class->finalize = gdk_pixbuf_loader_finalize;
-
-  pixbuf_loader_signals[AREA_PREPARED] =
-    g_signal_newc ("area_prepared",
-                   G_TYPE_FROM_CLASS (object_class),
-                   G_SIGNAL_RUN_LAST,
-                   G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_prepared),
-                   NULL,
-                   gtk_marshal_VOID__VOID,
-                   G_TYPE_NONE, 0);
-  
-  pixbuf_loader_signals[AREA_UPDATED] =
-    g_signal_newc ("area_updated",
-                   G_TYPE_FROM_CLASS (object_class),
-                   G_SIGNAL_RUN_LAST,
-                   G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_updated),
-                   NULL,
-                   gtk_marshal_VOID__INT_INT_INT_INT,
-                   G_TYPE_NONE, 4,
-                   G_TYPE_INT,
-                   G_TYPE_INT,
-                   G_TYPE_INT,
-                   G_TYPE_INT);
-  
-  pixbuf_loader_signals[FRAME_DONE] =
-    g_signal_newc ("frame_done",
-                   G_TYPE_FROM_CLASS (object_class),
-                   G_SIGNAL_RUN_LAST,
-                   G_STRUCT_OFFSET (GdkPixbufLoaderClass, frame_done),
-                   NULL,
-                   gtk_marshal_VOID__POINTER,
-                   G_TYPE_NONE, 1,
-                   GDK_TYPE_PIXBUF_FRAME);
-  
-  pixbuf_loader_signals[ANIMATION_DONE] =
-    g_signal_newc ("animation_done",
-                   G_TYPE_FROM_CLASS (object_class),
-                   G_SIGNAL_RUN_LAST,                   
-                   G_STRUCT_OFFSET (GdkPixbufLoaderClass, animation_done),
-                   NULL,
-                   gtk_marshal_VOID__VOID,
-                   G_TYPE_NONE, 0);
-  
-  pixbuf_loader_signals[CLOSED] =
-    g_signal_newc ("closed",
-                   G_TYPE_FROM_CLASS (object_class),
-                   G_SIGNAL_RUN_LAST,
-                   G_STRUCT_OFFSET (GdkPixbufLoaderClass, closed),
-                   NULL,
-                   gtk_marshal_VOID__VOID,
-                   G_TYPE_NONE, 0);
-}
-
-static void
-gdk_pixbuf_loader_init (GdkPixbufLoader *loader)
-{
-  GdkPixbufLoaderPrivate *priv;
-  
-  priv = g_new0 (GdkPixbufLoaderPrivate, 1);
-  loader->private = priv;
-}
-
-static void
-gdk_pixbuf_loader_finalize (GObject *object)
-{
-  GdkPixbufLoader *loader;
-  GdkPixbufLoaderPrivate *priv = NULL;
-  
-  loader = GDK_PIXBUF_LOADER (object);
-  priv = loader->private;
-
-  if (!priv->closed)
-    g_warning ("GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference.");
-  
-  if (priv->animation)
-    gdk_pixbuf_animation_unref (priv->animation);
-
-  if (priv->pixbuf)
-    gdk_pixbuf_unref (priv->pixbuf);
-  
-  g_free (priv);
-  
-  G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf,
-                          gpointer   loader)
-{
-  GdkPixbufLoaderPrivate *priv = NULL;
-  
-  priv = GDK_PIXBUF_LOADER (loader)->private;
-  gdk_pixbuf_ref (pixbuf);
-
-  g_assert (priv->pixbuf == NULL);
-  
-  priv->pixbuf = pixbuf;
-  g_signal_emit (G_OBJECT (loader), pixbuf_loader_signals[AREA_PREPARED], 0);
-}
-
-static void
-gdk_pixbuf_loader_update (GdkPixbuf *pixbuf,
-                         guint      x,
-                         guint      y,
-                         guint      width,
-                         guint      height,
-                         gpointer   loader)
-{
-  GdkPixbufLoaderPrivate *priv = NULL;
-  
-  priv = GDK_PIXBUF_LOADER (loader)->private;
-  
-  g_signal_emit (G_OBJECT (loader),
-                 pixbuf_loader_signals[AREA_UPDATED],
-                 0,
-                 x, y,
-                 /* sanity check in here.  Defend against an errant loader */
-                 MIN (width, gdk_pixbuf_get_width (priv->pixbuf)),
-                 MIN (height, gdk_pixbuf_get_height (priv->pixbuf)));
-}
-
-static void
-gdk_pixbuf_loader_frame_done (GdkPixbufFrame *frame,
-                             gpointer        loader)
-{
-  GdkPixbufLoaderPrivate *priv = NULL;
-  
-  priv = GDK_PIXBUF_LOADER (loader)->private;
-  
-  priv->pixbuf = NULL;
-  
-  if (priv->animation == NULL)
-    {
-      priv->animation = g_object_new (GDK_TYPE_PIXBUF_ANIMATION, NULL);
-      
-      priv->animation->n_frames = 0;
-      priv->animation->width  = gdk_pixbuf_get_width  (frame->pixbuf) + frame->x_offset;
-      priv->animation->height = gdk_pixbuf_get_height (frame->pixbuf) + frame->y_offset;
-    }
-  else
-    {
-      int w, h;
-      
-      /* update bbox size */
-      w = gdk_pixbuf_get_width (frame->pixbuf) + frame->x_offset;
-      h = gdk_pixbuf_get_height (frame->pixbuf) + frame->y_offset;
-      
-      if (w > priv->animation->width) {
-       priv->animation->width = w;
-      }
-      if (h > priv->animation->height) {
-       priv->animation->height = h;
-      }
-    }
-  
-  priv->animation->frames = g_list_append (priv->animation->frames, frame);
-  priv->animation->n_frames++;
-  g_signal_emit (G_OBJECT (loader),
-                 pixbuf_loader_signals[FRAME_DONE],
-                 0,
-                 frame);
-}
-
-static void
-gdk_pixbuf_loader_animation_done (GdkPixbuf *pixbuf,
-                                 gpointer   loader)
-{
-  GdkPixbufLoaderPrivate *priv = NULL;
-  GdkPixbufFrame    *frame;
-  GList *current = NULL;
-  gint h, w;
-  
-  priv = GDK_PIXBUF_LOADER (loader)->private;
-  priv->pixbuf = NULL;
-  
-  current = gdk_pixbuf_animation_get_frames (priv->animation);
-  
-  while (current)
-    {
-      frame = (GdkPixbufFrame *) current->data;
-      
-      /* update bbox size */
-      w = gdk_pixbuf_get_width (frame->pixbuf) + frame->x_offset;
-      h = gdk_pixbuf_get_height (frame->pixbuf) + frame->y_offset;
-      
-      if (w > priv->animation->width)
-       priv->animation->width = w;
-      if (h > priv->animation->height)
-       priv->animation->height = h;
-      current = current->next;
-    }
-  
-  g_signal_emit (G_OBJECT (loader), pixbuf_loader_signals[ANIMATION_DONE], 0);
-}
-
-static gint
-gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader,
-                               const char      *image_type,
-                               GError         **error)
-{
-  GdkPixbufLoaderPrivate *priv = loader->private;
-
-  if (image_type)
-    {
-      priv->image_module = gdk_pixbuf_get_named_module (image_type,
-                                                        error);
-    }
-  else
-    {
-      g_return_val_if_fail (priv->header_buf_offset > 0, 0);
-      priv->image_module = gdk_pixbuf_get_module (priv->header_buf,
-                                                  priv->header_buf_offset,
-                                                  NULL,
-                                                  error);
-    }
-  
-  if (priv->image_module == NULL)
-    return 0;
-  
-  if (priv->image_module->module == NULL)
-    if (!gdk_pixbuf_load_module (priv->image_module, error))
-      return 0;
-  
-  if (priv->image_module->module == NULL)
-    return 0;
-  
-  if ((priv->image_module->begin_load == NULL) ||
-      (priv->image_module->stop_load == NULL) ||
-      (priv->image_module->load_increment == NULL))
-    {
-      g_set_error (error,
-                   GDK_PIXBUF_ERROR,
-                   GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
-                   _("Incremental loading of image type '%s' is not supported"),
-                   image_type);
-
-      return 0;
-    }
-  
-  priv->context = priv->image_module->begin_load (gdk_pixbuf_loader_prepare,
-                                                 gdk_pixbuf_loader_update,
-                                                 gdk_pixbuf_loader_frame_done,
-                                                 gdk_pixbuf_loader_animation_done,
-                                                 loader,
-                                                  error);
-  
-  if (priv->context == NULL)
-    {
-      /* Defense against broken loaders; DO NOT take this as a GError
-       * example
-       */
-      if (error && *error == NULL)
-        {
-          g_warning ("Bug! loader '%s' didn't set an error on failure",
-                     priv->image_module->module_name);
-          g_set_error (error,
-                       GDK_PIXBUF_ERROR,
-                       GDK_PIXBUF_ERROR_FAILED,
-                       _("Internal error: Image loader module '%s'"
-                         " failed to begin loading an image, but didn't"
-                         " give a reason for the failure"),
-                       priv->image_module->module_name);
-
-        }
-      
-      return 0;
-    }
-  
-  if (priv->header_buf_offset
-      && priv->image_module->load_increment (priv->context, priv->header_buf, priv->header_buf_offset, error))
-    return priv->header_buf_offset;
-  
-  return 0;
-}
-
-static int
-gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader,
-                                   const guchar    *buf,
-                                   gsize            count,
-                                    GError         **error)
-{
-  gint n_bytes;
-  GdkPixbufLoaderPrivate *priv = loader->private;
-  
-  n_bytes = MIN(LOADER_HEADER_SIZE - priv->header_buf_offset, count);
-  memcpy (priv->header_buf + priv->header_buf_offset, buf, n_bytes);
-  
-  priv->header_buf_offset += n_bytes;
-  
-  if (priv->header_buf_offset >= LOADER_HEADER_SIZE)
-    {
-      if (gdk_pixbuf_loader_load_module (loader, NULL, error) == 0)
-       return 0;
-    }
-  
-  return n_bytes;
-}
-
-/**
- * gdk_pixbuf_loader_write:
- * @loader: A pixbuf loader.
- * @buf: Pointer to image data.
- * @count: Length of the @buf buffer in bytes.
- * @error: return location for errors
- *
- * This will cause a pixbuf loader to parse the next @count bytes of
- * an image.  It will return TRUE if the data was loaded successfully,
- * and FALSE if an error occurred.  In the latter case, the loader
- * will be closed, and will not accept further writes. If FALSE is
- * returned, @error will be set to an error from the #GDK_PIXBUF_ERROR
- * domain.
- *
- * Return value: #TRUE if the write was successful, or #FALSE if the loader
- * cannot parse the buffer.
- **/
-gboolean
-gdk_pixbuf_loader_write (GdkPixbufLoader *loader,
-                        const guchar    *buf,
-                        gsize            count,
-                         GError         **error)
-{
-  GdkPixbufLoaderPrivate *priv;
-  
-  g_return_val_if_fail (loader != NULL, FALSE);
-  g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), FALSE);
-  
-  g_return_val_if_fail (buf != NULL, FALSE);
-  g_return_val_if_fail (count >= 0, FALSE);
-  
-  priv = loader->private;
-  
-  /* we expect it's not to be closed */
-  g_return_val_if_fail (priv->closed == FALSE, FALSE);
-  
-  if (priv->image_module == NULL)
-    {
-      gint eaten;
-      
-      eaten = gdk_pixbuf_loader_eat_header_write(loader, buf, count, error);
-      if (eaten <= 0)
-       return FALSE;
-      
-      count -= eaten;
-      buf += eaten;
-    }
-  
-  if (count > 0 && priv->image_module->load_increment)
-    {
-      gboolean retval;
-      retval = priv->image_module->load_increment (priv->context, buf, count,
-                                                   error);
-      if (!retval && error && *error == NULL)
-        {
-          /* Fix up busted image loader */
-          g_warning ("Bug! loader '%s' didn't set an error on failure",
-                     priv->image_module->module_name);
-          g_set_error (error,
-                       GDK_PIXBUF_ERROR,
-                       GDK_PIXBUF_ERROR_FAILED,
-                       _("Internal error: Image loader module '%s'"
-                         " failed to begin loading an image, but didn't"
-                         " give a reason for the failure"),
-                       priv->image_module->module_name);
-        }
-
-      return retval;
-    }
-      
-  return TRUE;
-}
-
-/**
- * gdk_pixbuf_loader_new:
- *
- * Creates a new pixbuf loader object.
- *
- * Return value: A newly-created pixbuf loader.
- **/
-GdkPixbufLoader *
-gdk_pixbuf_loader_new (void)
-{
-  return g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL);
-}
-
-/**
- * gdk_pixbuf_loader_new_with_type:
- *
- * Creates a new pixbuf loader object.
- *
- * Return value: A newly-created pixbuf loader.
- **/
-GdkPixbufLoader *
-gdk_pixbuf_loader_new_with_type (const char *image_type,
-                                 GError    **error)
-{
-  GdkPixbufLoader *retval;
-  GError *tmp;
-  
-  retval = g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL);
-
-  tmp = NULL;
-  gdk_pixbuf_loader_load_module(retval, image_type, &tmp);
-  if (tmp != NULL)
-    {
-      g_propagate_error (error, tmp);
-      g_object_unref (G_OBJECT (retval));
-      return NULL;
-    }
-
-  return retval;
-}
-
-/**
- * gdk_pixbuf_loader_get_pixbuf:
- * @loader: A pixbuf loader.
- *
- * Queries the GdkPixbuf that a pixbuf loader is currently creating.
- * In general it only makes sense to call this function afer the
- * "area_prepared" signal has been emitted by the loader; this means
- * that enough data has been read to know the size of the image that
- * will be allocated.  If the loader has not received enough data via
- * gdk_pixbuf_loader_write(), then this function returns NULL.  The
- * returned pixbuf will be the same in all future calls to the loader,
- * so simply calling gdk_pixbuf_ref() should be sufficient to continue
- * using it.  Additionally, if the loader is an animation, it will
- * return the first frame of the animation.
- * 
- * Return value: The GdkPixbuf that the loader is creating, or NULL if not
- * enough data has been read to determine how to create the image buffer.
- **/
-GdkPixbuf *
-gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader)
-{
-  GdkPixbufLoaderPrivate *priv;
-  
-  g_return_val_if_fail (loader != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
-  
-  priv = loader->private;
-
-  if (priv->animation)
-    {
-      GList *list;
-      
-      list = gdk_pixbuf_animation_get_frames (priv->animation);
-      if (list != NULL)
-        {
-          GdkPixbufFrame *frame = list->data;
-          
-          return gdk_pixbuf_frame_get_pixbuf (frame);
-        }
-    }
-  
-  return priv->pixbuf;
-}
-
-/**
- * gdk_pixbuf_loader_get_animation:
- * @loader: A pixbuf loader
- *
- * Queries the GdkPixbufAnimation that a pixbuf loader is currently creating.
- * In general it only makes sense to call this function afer the "area_prepared"
- * signal has been emitted by the loader.  If the image is not an animation,
- * then it will return NULL.
- *
- * Return value: The GdkPixbufAnimation that the loader is loading, or NULL if
- not enough data has been read to determine the information.
-**/
-GdkPixbufAnimation *
-gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader)
-{
-  GdkPixbufLoaderPrivate *priv;
-  
-  g_return_val_if_fail (loader != NULL, NULL);
-  g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
-  
-  priv = loader->private;
-  
-  return priv->animation;
-}
-
-/**
- * gdk_pixbuf_loader_close:
- * @loader: A pixbuf loader.
- *
- * Informs a pixbuf loader that no further writes with gdk_pixbuf_loader_write()
- * will occur, so that it can free its internal loading structures.
- **/
-void
-gdk_pixbuf_loader_close (GdkPixbufLoader *loader)
-{
-  GdkPixbufLoaderPrivate *priv;
-  
-  g_return_if_fail (loader != NULL);
-  g_return_if_fail (GDK_IS_PIXBUF_LOADER (loader));
-  
-  priv = loader->private;
-  
-  /* we expect it's not closed */
-  g_return_if_fail (priv->closed == FALSE);
-  
-  /* We have less the 128 bytes in the image.  Flush it, and keep going. */
-  if (priv->image_module == NULL)
-    gdk_pixbuf_loader_load_module (loader, NULL, NULL);
-  
-  if (priv->image_module && priv->image_module->stop_load)
-    priv->image_module->stop_load (priv->context);
-  
-  priv->closed = TRUE;
-  
-  g_signal_emit (G_OBJECT (loader), pixbuf_loader_signals[CLOSED], 0);
-}
diff --git a/gtk/gdk-pixbuf-loader.h b/gtk/gdk-pixbuf-loader.h
deleted file mode 100644 (file)
index 01532ad..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* GdkPixbuf library - Progressive loader object
- *
- * Copyright (C) 1999 The Free Software Foundation
- *
- * Authors: Mark Crichton <crichton@gimp.org>
- *          Miguel de Icaza <miguel@gnu.org>
- *          Federico Mena-Quintero <federico@gimp.org>
- *          Jonathan Blandford <jrb@redhat.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef GDK_PIXBUF_LOADER_H
-#define GDK_PIXBUF_LOADER_H
-
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define GDK_TYPE_PIXBUF_LOADER            (gdk_pixbuf_loader_get_type ())
-#define GDK_PIXBUF_LOADER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoader))
-#define GDK_PIXBUF_LOADER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoaderClass))
-#define GDK_IS_PIXBUF_LOADER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PIXBUF_LOADER))
-#define GDK_IS_PIXBUF_LOADER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_LOADER))
-#define GDK_PIXBUF_LOADER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoaderClass))
-
-
-typedef struct _GdkPixbufLoader GdkPixbufLoader;
-struct _GdkPixbufLoader
-{
-  GObject parent_instance;
-  
-  /*< private >*/
-  gpointer private;
-};
-
-typedef struct _GdkPixbufLoaderClass GdkPixbufLoaderClass;
-struct _GdkPixbufLoaderClass
-{
-  GObjectClass parent_class;
-  
-  void (*area_prepared)   (GdkPixbufLoader *loader);
-  void (*area_updated)    (GdkPixbufLoader *loader,
-                          guint            x,
-                          guint            y,
-                          guint            width,
-                          guint            height);
-  void (*frame_done)      (GdkPixbufLoader *loader,
-                          GdkPixbufFrame  *frame);
-  void (*animation_done)  (GdkPixbufLoader *loader);
-  void (*closed)          (GdkPixbufLoader *loader);
-};
-
-
-GType              gdk_pixbuf_loader_get_type      (void) G_GNUC_CONST;
-GdkPixbufLoader *    gdk_pixbuf_loader_new           (void);
-GdkPixbufLoader *    gdk_pixbuf_loader_new_with_type (const char *image_type,
-                                                      GError    **error);
-gboolean             gdk_pixbuf_loader_write         (GdkPixbufLoader *loader,
-                                                     const guchar    *buf,
-                                                     gsize            count,
-                                                      GError         **error);
-GdkPixbuf *          gdk_pixbuf_loader_get_pixbuf    (GdkPixbufLoader *loader);
-GdkPixbufAnimation * gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader);
-void                 gdk_pixbuf_loader_close         (GdkPixbufLoader *loader);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
index 5529e61bb53e7f81e037291dbd9a6c160a5eb1d4..549dcb2179d2b429c757e2672d5869e2c9b881c6 100644 (file)
@@ -2447,6 +2447,8 @@ typedef gboolean (* TestLogAttrFunc) (const PangoLogAttr *attrs,
                                       gint                min_offset,
                                       gint                len);
 
+/* Word funcs */
+
 static gboolean
 find_word_end_func (const PangoLogAttr *attrs,
                     gint          offset,
@@ -2521,6 +2523,82 @@ inside_word_func (const PangoLogAttr *attrs,
   return attrs[offset].is_word_start;
 }
 
+/* Sentence funcs */
+
+static gboolean
+find_sentence_end_func (const PangoLogAttr *attrs,
+                        gint          offset,
+                        gint          min_offset,
+                        gint          len,
+                        gint         *found_offset,
+                        gboolean      already_moved_initially)
+{
+  if (!already_moved_initially)
+    ++offset;
+
+  /* Find end of next sentence */
+  while (offset < min_offset + len &&
+         !attrs[offset].is_sentence_end)
+    ++offset;
+
+  *found_offset = offset;
+
+  return offset < min_offset + len;
+}
+
+static gboolean
+is_sentence_end_func (const PangoLogAttr *attrs,
+                      gint          offset,
+                      gint          min_offset,
+                      gint          len)
+{
+  return attrs[offset].is_sentence_end;
+}
+
+static gboolean
+find_sentence_start_func (const PangoLogAttr *attrs,
+                          gint          offset,
+                          gint          min_offset,
+                          gint          len,
+                          gint         *found_offset,
+                          gboolean      already_moved_initially)
+{
+  if (!already_moved_initially)
+    --offset;
+
+  /* Find start of prev sentence */
+  while (offset >= min_offset &&
+         !attrs[offset].is_sentence_start)
+    --offset;
+
+  *found_offset = offset;
+
+  return offset >= min_offset;
+}
+
+static gboolean
+is_sentence_start_func (const PangoLogAttr *attrs,
+                        gint          offset,
+                        gint          min_offset,
+                        gint          len)
+{
+  return attrs[offset].is_sentence_start;
+}
+
+static gboolean
+inside_sentence_func (const PangoLogAttr *attrs,
+                      gint          offset,
+                      gint          min_offset,
+                      gint          len)
+{
+  /* Find next sentence start or end */
+  while (offset >= min_offset &&
+         !(attrs[offset].is_sentence_start || attrs[offset].is_sentence_end))
+    --offset;
+
+  return attrs[offset].is_sentence_start;
+}
+
 static gboolean
 test_log_attrs (const GtkTextIter *iter,
                 TestLogAttrFunc    func)
@@ -2683,7 +2761,6 @@ gtk_text_iter_backward_word_starts (GtkTextIter      *iter,
   return TRUE;
 }
 
-
 gboolean
 gtk_text_iter_starts_word (const GtkTextIter *iter)
 {
@@ -2702,6 +2779,86 @@ gtk_text_iter_inside_word (const GtkTextIter *iter)
   return test_log_attrs (iter, inside_word_func);
 }
 
+gboolean
+gtk_text_iter_starts_sentence (const GtkTextIter *iter)
+{
+  return test_log_attrs (iter, is_sentence_start_func);
+}
+
+gboolean
+gtk_text_iter_ends_sentence (const GtkTextIter *iter)
+{
+  return test_log_attrs (iter, is_sentence_end_func);
+}
+
+gboolean
+gtk_text_iter_inside_sentence (const GtkTextIter *iter)
+{
+  return test_log_attrs (iter, inside_sentence_func);
+}
+
+gboolean
+gtk_text_iter_forward_sentence_end (GtkTextIter *iter)
+{
+  return find_by_log_attrs (iter, find_sentence_end_func, TRUE, FALSE);
+}
+
+gboolean
+gtk_text_iter_backward_sentence_start (GtkTextIter      *iter)
+{
+  return find_by_log_attrs (iter, find_sentence_start_func, FALSE, FALSE);
+}
+
+/* FIXME a loop around a truly slow function means
+ * a truly spectacularly slow function.
+ */
+gboolean
+gtk_text_iter_forward_sentence_ends (GtkTextIter      *iter,
+                                     gint              count)
+{
+  g_return_val_if_fail (iter != NULL, FALSE);
+
+  if (count == 0)
+    return FALSE;
+
+  if (count < 0)
+    return gtk_text_iter_backward_sentence_starts (iter, -count);
+
+  if (!gtk_text_iter_forward_sentence_end (iter))
+    return FALSE;
+  --count;
+
+  while (count > 0)
+    {
+      if (!gtk_text_iter_forward_sentence_end (iter))
+        break;
+      --count;
+    }
+  return TRUE;
+}
+
+gboolean
+gtk_text_iter_backward_sentence_starts (GtkTextIter      *iter,
+                                        gint               count)
+{
+  g_return_val_if_fail (iter != NULL, FALSE);
+
+  if (count < 0)
+    return gtk_text_iter_forward_sentence_ends (iter, -count);
+
+  if (!gtk_text_iter_backward_sentence_start (iter))
+    return FALSE;
+  --count;
+
+  while (count > 0)
+    {
+      if (!gtk_text_iter_backward_sentence_start (iter))
+        break;
+      --count;
+    }
+  return TRUE;
+}
+
 static gboolean
 find_forward_cursor_pos_func (const PangoLogAttr *attrs,
                               gint          offset,
index ddb86dd79da64f94030331d840bcd10b208ac35c..2522588a7ad858f3e25199101deb96b0e0cda7a2 100644 (file)
@@ -128,6 +128,9 @@ gboolean gtk_text_iter_editable          (const GtkTextIter   *iter,
 gboolean gtk_text_iter_starts_word        (const GtkTextIter   *iter);
 gboolean gtk_text_iter_ends_word          (const GtkTextIter   *iter);
 gboolean gtk_text_iter_inside_word        (const GtkTextIter   *iter);
+gboolean gtk_text_iter_starts_sentence    (const GtkTextIter   *iter);
+gboolean gtk_text_iter_ends_sentence      (const GtkTextIter   *iter);
+gboolean gtk_text_iter_inside_sentence    (const GtkTextIter   *iter);
 gboolean gtk_text_iter_starts_line        (const GtkTextIter   *iter);
 gboolean gtk_text_iter_ends_line          (const GtkTextIter   *iter);
 gboolean gtk_text_iter_is_cursor_position (const GtkTextIter   *iter);
@@ -163,6 +166,13 @@ gboolean gtk_text_iter_forward_word_ends    (GtkTextIter *iter,
                                              gint         count);
 gboolean gtk_text_iter_backward_word_starts (GtkTextIter *iter,
                                              gint         count);
+
+gboolean gtk_text_iter_forward_sentence_end     (GtkTextIter *iter);
+gboolean gtk_text_iter_backward_sentence_start  (GtkTextIter *iter);
+gboolean gtk_text_iter_forward_sentence_ends    (GtkTextIter *iter,
+                                                 gint         count);
+gboolean gtk_text_iter_backward_sentence_starts (GtkTextIter *iter,
+                                                 gint         count);
 /* cursor positions are almost equivalent to chars, but not quite;
  * in some languages, you can't put the cursor between certain
  * chars. Also, you can't put the cursor between \r\n at the end
index bd10489b2de2269d93b2dcc478f8223ed39386ba..01c8177a91b5f67d33918f34f98721c8cf8cc9b9 100644 (file)
@@ -1069,7 +1069,7 @@ set_para_values (GtkTextLayout      *layout,
   else
     display->layout = pango_layout_new (layout->rtl_context);
 
-  switch (style->justify)
+  switch (style->justification)
     {
     case GTK_JUSTIFY_LEFT:
       pango_align = (style->direction == GTK_TEXT_DIR_LTR) ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT;
@@ -1122,11 +1122,17 @@ set_para_values (GtkTextLayout      *layout,
   switch (style->wrap_mode)
     {
     case GTK_WRAPMODE_CHAR:
-      /* FIXME: Handle this; for now, fall-through */
+      layout_width = layout->screen_width - display->left_margin - display->right_margin;
+      pango_layout_set_width (display->layout, layout_width * PANGO_SCALE);
+      pango_layout_set_wrap (display->layout, PANGO_WRAP_CHAR);
+      break;
+
     case GTK_WRAPMODE_WORD:
       layout_width = layout->screen_width - display->left_margin - display->right_margin;
       pango_layout_set_width (display->layout, layout_width * PANGO_SCALE);
+      pango_layout_set_wrap (display->layout, PANGO_WRAP_WORD);
       break;
+
     case GTK_WRAPMODE_NONE:
       break;
     }
index f2911c5ea2adabcf173bb09810225dca85f276c7..1e3d51bfbbf07260d4ddb3b64f4efc5a90f6302d 100644 (file)
@@ -90,7 +90,7 @@ enum {
   PROP_PIXELS_INSIDE_WRAP,
   PROP_EDITABLE,
   PROP_WRAP_MODE,
-  PROP_JUSTIFY,
+  PROP_JUSTIFICATION,
   PROP_DIRECTION,
   PROP_LEFT_MARGIN,
   PROP_INDENT,
@@ -121,7 +121,7 @@ enum {
   PROP_PIXELS_INSIDE_WRAP_SET,
   PROP_EDITABLE_SET,
   PROP_WRAP_MODE_SET,
-  PROP_JUSTIFY_SET,
+  PROP_JUSTIFICATION_SET,
   PROP_LEFT_MARGIN_SET,
   PROP_INDENT_SET,
   PROP_STRIKETHROUGH_SET,
@@ -364,8 +364,8 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));  
 
   g_object_class_install_property (object_class,
-                                   PROP_JUSTIFY,
-                                   g_param_spec_enum ("justify",
+                                   PROP_JUSTIFICATION,
+                                   g_param_spec_enum ("justification",
                                                       _("Justification"),
                                                       _("Left, right, or center justification"),
                                                       GTK_TYPE_JUSTIFICATION,
@@ -555,7 +555,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                 _("Font size set"),
                 _("Whether this tag affects the font size"));
 
-  ADD_SET_PROP ("justify_set", PROP_JUSTIFY_SET,
+  ADD_SET_PROP ("justification_set", PROP_JUSTIFICATION_SET,
                 _("Justification set"),
                 _("Whether this tag affects paragraph justification"));
   
@@ -998,10 +998,10 @@ gtk_text_tag_set_property (GObject      *object,
       size_changed = TRUE;
       break;
 
-    case PROP_JUSTIFY:
-      text_tag->justify_set = TRUE;
-      text_tag->values->justify = g_value_get_enum (value);
-      g_object_notify (G_OBJECT (text_tag), "justify_set");
+    case PROP_JUSTIFICATION:
+      text_tag->justification_set = TRUE;
+      text_tag->values->justification = g_value_get_enum (value);
+      g_object_notify (G_OBJECT (text_tag), "justification_set");
       size_changed = TRUE;
       break;
 
@@ -1169,8 +1169,8 @@ gtk_text_tag_set_property (GObject      *object,
       size_changed = TRUE;
       break;
 
-    case PROP_JUSTIFY_SET:
-      text_tag->justify_set = g_value_get_boolean (value);
+    case PROP_JUSTIFICATION_SET:
+      text_tag->justification_set = g_value_get_boolean (value);
       size_changed = TRUE;
       break;
       
@@ -1363,8 +1363,8 @@ gtk_text_tag_get_property (GObject      *object,
       g_value_set_enum (value, tag->values->wrap_mode);
       break;
 
-    case PROP_JUSTIFY:
-      g_value_set_enum (value, tag->values->justify);
+    case PROP_JUSTIFICATION:
+      g_value_set_enum (value, tag->values->justification);
       break;
 
     case PROP_DIRECTION:
@@ -1474,8 +1474,8 @@ gtk_text_tag_get_property (GObject      *object,
       g_value_set_boolean (value, tag->wrap_mode_set);
       break;
 
-    case PROP_JUSTIFY_SET:
-      g_value_set_boolean (value, tag->justify_set);
+    case PROP_JUSTIFICATION_SET:
+      g_value_set_boolean (value, tag->justification_set);
       break;
       
     case PROP_LEFT_MARGIN_SET:
@@ -1952,8 +1952,8 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
       if (tag->size_set)
         dest->font.size = vals->font.size;
 
-      if (tag->justify_set)
-        dest->justify = vals->justify;
+      if (tag->justification_set)
+        dest->justification = vals->justification;
 
       if (vals->direction != GTK_TEXT_DIR_NONE)
         dest->direction = vals->direction;
@@ -2026,7 +2026,7 @@ _gtk_text_tag_affects_size (GtkTextTag *tag)
     tag->weight_set ||
     tag->size_set ||
     tag->stretch_set ||
-    tag->justify_set ||
+    tag->justification_set ||
     tag->left_margin_set ||
     tag->indent_set ||
     tag->rise_set ||
index 2b92cda9685c6a3fecada782b2372caffa934da7..f4abd8e174ba9dbcc8998023cd35506724146d1a 100644 (file)
@@ -68,7 +68,7 @@ struct _GtkTextTag
   guint stretch_set : 1;
   guint size_set : 1;
   guint fg_stipple_set : 1;
-  guint justify_set : 1;
+  guint justification_set : 1;
   guint left_margin_set : 1;
   guint indent_set : 1;
   guint rise_set : 1;
@@ -148,7 +148,7 @@ struct _GtkTextAttributes
 
   GtkTextAppearance appearance;
 
-  GtkJustification justify;
+  GtkJustification justification;
   GtkTextDirection direction;
 
   /* Individual chunks of this can be set/unset as a group */
index b895960dc23e8753ee685dbaacfb9d790c7c945b..659656b7be57fcdac4c3c81e33f66e84467c42fa 100644 (file)
@@ -1728,7 +1728,7 @@ gtk_text_view_set_justification (GtkTextView     *text_view,
 
       if (text_view->layout)
         {
-          text_view->layout->default_style->justify = justify;
+          text_view->layout->default_style->justification = justify;
           gtk_text_layout_default_style_changed (text_view->layout);
         }
     }
@@ -3458,9 +3458,15 @@ gtk_text_view_start_cursor_blink(GtkTextView *text_view,
 #ifdef DEBUG_VALIDATION_AND_SCROLLING
   return;
 #endif
+
+  if (text_view->layout == NULL)
+    return;
   
   if (!text_view->cursor_visible)
     return;
+
+  if (!GTK_WIDGET_HAS_FOCUS (text_view))
+    return;
   
   if (text_view->preblink_timeout != 0)
     {
@@ -4140,7 +4146,7 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
       style->tabs = text_view->tabs ? pango_tab_array_copy (text_view->tabs) : NULL;
 
       style->wrap_mode = text_view->wrap_mode;
-      style->justify = text_view->justify;
+      style->justification = text_view->justify;
       style->direction = gtk_widget_get_direction (GTK_WIDGET (text_view));
 
       gtk_text_layout_set_default_style (text_view->layout, style);
index 3086f0bdbdffe8074f5a0d63dcbbd1e9349df8de..9a66df2cb9722150cb7f9a63fb361db69090a0cf 100644 (file)
@@ -470,17 +470,17 @@ fill_example_buffer (GtkTextBuffer *buffer)
   color.blue = color.red = 0;
   color.green = 0xffff;
   g_object_set (G_OBJECT (tag),
-                  "background_gdk", &color,
-                  "size_points", 10.0,
-                  NULL);
+                "background_gdk", &color,
+                "size_points", 10.0,
+                NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "strikethrough");
 
   setup_tag (tag);
       
   g_object_set (G_OBJECT (tag),
-                  "strikethrough", TRUE,
-                  NULL);
+                "strikethrough", TRUE,
+                NULL);
 
 
   tag = gtk_text_buffer_create_tag (buffer, "underline");
@@ -488,30 +488,30 @@ fill_example_buffer (GtkTextBuffer *buffer)
   setup_tag (tag);
       
   g_object_set (G_OBJECT (tag),
-                  "underline", PANGO_UNDERLINE_SINGLE,
-                  NULL);
+                "underline", PANGO_UNDERLINE_SINGLE,
+                NULL);
 
   setup_tag (tag);
       
   g_object_set (G_OBJECT (tag),
-                  "underline", PANGO_UNDERLINE_SINGLE,
-                  NULL);
+                "underline", PANGO_UNDERLINE_SINGLE,
+                NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "centered");
       
   g_object_set (G_OBJECT (tag),
-                  "justify", GTK_JUSTIFY_CENTER,
-                  NULL);
+                "justification", GTK_JUSTIFY_CENTER,
+                NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "rtl_quote");
       
   g_object_set (G_OBJECT (tag),
-                  "wrap_mode", GTK_WRAPMODE_WORD,
-                  "direction", GTK_TEXT_DIR_RTL,
-                  "indent", 30,
-                  "left_margin", 20,
-                  "right_margin", 20,
-                  NULL);
+                "wrap_mode", GTK_WRAPMODE_WORD,
+                "direction", GTK_TEXT_DIR_RTL,
+                "indent", 30,
+                "left_margin", 20,
+                "right_margin", 20,
+                NULL);
 
 
 #if 0
@@ -1182,6 +1182,9 @@ view_init_menus (View *view)
     case GTK_WRAPMODE_WORD:
       menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Words");
       break;
+    case GTK_WRAPMODE_CHAR:
+      menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Chars");
+      break;
     default:
       break;
     }
@@ -1208,6 +1211,7 @@ static GtkItemFactoryEntry menu_items[] =
   { "/_Settings",        NULL,         0,                0, "<Branch>" },
   { "/Settings/Wrap _Off",   NULL,      do_wrap_changed,  GTK_WRAPMODE_NONE, "<RadioItem>" },
   { "/Settings/Wrap _Words", NULL,      do_wrap_changed,  GTK_WRAPMODE_WORD, "/Settings/Wrap Off" },
+  { "/Settings/Wrap _Chars", NULL,      do_wrap_changed,  GTK_WRAPMODE_CHAR, "/Settings/Wrap Off" },
   { "/Settings/sep1",        NULL,      0,                0, "<Separator>" },
   { "/Settings/Editable", NULL,      do_editable_changed,  TRUE, "<RadioItem>" },
   { "/Settings/Not editable",    NULL,      do_editable_changed,  FALSE, "/Settings/Editable" },
index 3086f0bdbdffe8074f5a0d63dcbbd1e9349df8de..9a66df2cb9722150cb7f9a63fb361db69090a0cf 100644 (file)
@@ -470,17 +470,17 @@ fill_example_buffer (GtkTextBuffer *buffer)
   color.blue = color.red = 0;
   color.green = 0xffff;
   g_object_set (G_OBJECT (tag),
-                  "background_gdk", &color,
-                  "size_points", 10.0,
-                  NULL);
+                "background_gdk", &color,
+                "size_points", 10.0,
+                NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "strikethrough");
 
   setup_tag (tag);
       
   g_object_set (G_OBJECT (tag),
-                  "strikethrough", TRUE,
-                  NULL);
+                "strikethrough", TRUE,
+                NULL);
 
 
   tag = gtk_text_buffer_create_tag (buffer, "underline");
@@ -488,30 +488,30 @@ fill_example_buffer (GtkTextBuffer *buffer)
   setup_tag (tag);
       
   g_object_set (G_OBJECT (tag),
-                  "underline", PANGO_UNDERLINE_SINGLE,
-                  NULL);
+                "underline", PANGO_UNDERLINE_SINGLE,
+                NULL);
 
   setup_tag (tag);
       
   g_object_set (G_OBJECT (tag),
-                  "underline", PANGO_UNDERLINE_SINGLE,
-                  NULL);
+                "underline", PANGO_UNDERLINE_SINGLE,
+                NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "centered");
       
   g_object_set (G_OBJECT (tag),
-                  "justify", GTK_JUSTIFY_CENTER,
-                  NULL);
+                "justification", GTK_JUSTIFY_CENTER,
+                NULL);
 
   tag = gtk_text_buffer_create_tag (buffer, "rtl_quote");
       
   g_object_set (G_OBJECT (tag),
-                  "wrap_mode", GTK_WRAPMODE_WORD,
-                  "direction", GTK_TEXT_DIR_RTL,
-                  "indent", 30,
-                  "left_margin", 20,
-                  "right_margin", 20,
-                  NULL);
+                "wrap_mode", GTK_WRAPMODE_WORD,
+                "direction", GTK_TEXT_DIR_RTL,
+                "indent", 30,
+                "left_margin", 20,
+                "right_margin", 20,
+                NULL);
 
 
 #if 0
@@ -1182,6 +1182,9 @@ view_init_menus (View *view)
     case GTK_WRAPMODE_WORD:
       menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Words");
       break;
+    case GTK_WRAPMODE_CHAR:
+      menu_item = gtk_item_factory_get_widget (view->item_factory, "/Settings/Wrap Chars");
+      break;
     default:
       break;
     }
@@ -1208,6 +1211,7 @@ static GtkItemFactoryEntry menu_items[] =
   { "/_Settings",        NULL,         0,                0, "<Branch>" },
   { "/Settings/Wrap _Off",   NULL,      do_wrap_changed,  GTK_WRAPMODE_NONE, "<RadioItem>" },
   { "/Settings/Wrap _Words", NULL,      do_wrap_changed,  GTK_WRAPMODE_WORD, "/Settings/Wrap Off" },
+  { "/Settings/Wrap _Chars", NULL,      do_wrap_changed,  GTK_WRAPMODE_CHAR, "/Settings/Wrap Off" },
   { "/Settings/sep1",        NULL,      0,                0, "<Separator>" },
   { "/Settings/Editable", NULL,      do_editable_changed,  TRUE, "<RadioItem>" },
   { "/Settings/Not editable",    NULL,      do_editable_changed,  FALSE, "/Settings/Editable" },